[gtk/internal-test-option] build: Add a build-internal-tests option




commit 4847666a1295baa0b77107fa87ecc475df50a15f
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Sep 14 11:28:13 2021 -0400

    build: Add a build-internal-tests option
    
    Internal tests link against the static library,
    which takes a *long* time. Making it possible
    to run only the public api tests is good for
    faster turnaround times.

 meson_options.txt         |  5 ++++
 testsuite/css/meson.build | 52 ++++++++++++++++++++--------------------
 testsuite/gsk/meson.build | 52 ++++++++++++++++++++--------------------
 testsuite/gtk/meson.build | 60 ++++++++++++++++++++++++-----------------------
 4 files changed, 89 insertions(+), 80 deletions(-)
---
diff --git a/meson_options.txt b/meson_options.txt
index 61878ceba4..657514a5fb 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -119,6 +119,11 @@ option('build-tests',
        value: 'true',
        description : 'Build tests')
 
+option('build-internal-tests',
+       type: 'boolean',
+       value: 'true',
+       description : 'Build tests for internal apis')
+
 option('install-tests',
        type: 'boolean',
        value: 'false',
diff --git a/testsuite/css/meson.build b/testsuite/css/meson.build
index 20c031410d..d48c57a4dd 100644
--- a/testsuite/css/meson.build
+++ b/testsuite/css/meson.build
@@ -30,34 +30,36 @@ test('api', test_api,
   suite: 'css',
 )
 
-test_data = executable('data', 'data.c',
-  c_args: common_cflags,
-  include_directories: [confinc, ],
-  dependencies: libgtk_static_dep,
-  install: get_option('install-tests'),
-  install_dir: testexecdir,
-)
+if get_option('build-internal-tests')
+  test_data = executable('data', 'data.c',
+    c_args: common_cflags,
+    include_directories: [confinc, ],
+    dependencies: libgtk_static_dep,
+    install: get_option('install-tests'),
+    install_dir: testexecdir,
+  )
 
-test('data', test_data,
-  args: ['--tap', '-k' ],
-  protocol: 'tap',
-  env: csstest_env,
-  suite: 'css',
-)
+  test('data', test_data,
+    args: ['--tap', '-k' ],
+    protocol: 'tap',
+    env: csstest_env,
+    suite: 'css',
+  )
 
-transition = executable('transition', 'transition.c',
-  c_args: common_cflags,
-  dependencies: libgtk_static_dep,
-  install: get_option('install-tests'),
-  install_dir: testexecdir,
-)
+  transition = executable('transition', 'transition.c',
+    c_args: common_cflags,
+    dependencies: libgtk_static_dep,
+    install: get_option('install-tests'),
+    install_dir: testexecdir,
+  )
 
-test('transition', transition,
-     args: [ '--tap', '-k' ],
-     protocol: 'tap',
-     env: csstest_env,
-     suite: 'css'
-)
+  test('transition', transition,
+       args: [ '--tap', '-k' ],
+       protocol: 'tap',
+       env: csstest_env,
+       suite: 'css'
+  )
+endif
 
 if get_option('install-tests')
   conf = configuration_data()
diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build
index e6901e5ef9..c8cc3cca32 100644
--- a/testsuite/gsk/meson.build
+++ b/testsuite/gsk/meson.build
@@ -239,31 +239,31 @@ internal_tests = [
   [ 'half-float' ],
 ]
 
-foreach t : internal_tests
-  test_name = t.get(0)
-  test_srcs = ['@0@.c'.format(test_name)] + t.get(1, [])
-  test_extra_cargs = t.get(2, [])
-  test_extra_ldflags = t.get(3, [])
-
-  test_exe = executable(test_name, test_srcs,
-    c_args : test_cargs + test_extra_cargs + common_cflags,
-    link_args : test_extra_ldflags,
-    dependencies : libgtk_static_dep,
-    install: get_option('install-tests'),
-    install_dir: testexecdir,
-  )
-
-  test(test_name, test_exe,
-    args: [ '--tap', '-k' ],
-    protocol: 'tap',
-    env: [
-      'GSK_RENDERER=cairo',
-      'GTK_A11Y=test',
-      'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-      'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
-    ],
-    suite: 'gsk',
-  )
-endforeach
+if get_option('build-internal-tests')
+  foreach t : internal_tests
+    test_name = t.get(0)
+    test_srcs = ['@0@.c'.format(test_name)] + t.get(1, [])
+    test_extra_cargs = t.get(2, [])
+    test_extra_ldflags = t.get(3, [])
 
+    test_exe = executable(test_name, test_srcs,
+      c_args : test_cargs + test_extra_cargs + common_cflags,
+      link_args : test_extra_ldflags,
+      dependencies : libgtk_static_dep,
+      install: get_option('install-tests'),
+      install_dir: testexecdir,
+    )
 
+    test(test_name, test_exe,
+      args: [ '--tap', '-k' ],
+      protocol: 'tap',
+      env: [
+        'GSK_RENDERER=cairo',
+        'GTK_A11Y=test',
+        'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+        'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
+      ],
+      suite: 'gsk',
+    )
+  endforeach
+endif
diff --git a/testsuite/gtk/meson.build b/testsuite/gtk/meson.build
index b628b07dc2..ca6044df65 100644
--- a/testsuite/gtk/meson.build
+++ b/testsuite/gtk/meson.build
@@ -190,38 +190,40 @@ foreach t : tests
   )
 endforeach
 
-foreach t : internal_tests
-  test_name = t.get('name')
-  test_srcs = ['@0@.c'.format(test_name)] + t.get('sources', [])
-  test_extra_cargs = t.get('c_args', [])
-  test_extra_ldflags = t.get('link_args', [])
-  test_extra_suites = t.get('suites', [])
-  test_timeout = 60
-
-  test_exe = executable(test_name,
-    sources: test_srcs,
-    c_args: test_cargs + test_extra_cargs,
-    link_args: test_extra_ldflags,
-    dependencies: libgtk_static_dep,
-    install: get_option('install-tests'),
-    install_dir: testexecdir,
-  )
+if get_option('build-internal-tests')
+  foreach t : internal_tests
+    test_name = t.get('name')
+    test_srcs = ['@0@.c'.format(test_name)] + t.get('sources', [])
+    test_extra_cargs = t.get('c_args', [])
+    test_extra_ldflags = t.get('link_args', [])
+    test_extra_suites = t.get('suites', [])
+    test_timeout = 60
+
+    test_exe = executable(test_name,
+      sources: test_srcs,
+      c_args: test_cargs + test_extra_cargs,
+      link_args: test_extra_ldflags,
+      dependencies: libgtk_static_dep,
+      install: get_option('install-tests'),
+      install_dir: testexecdir,
+    )
 
-  expect_fail = xfail.contains(test_name)
+    expect_fail = xfail.contains(test_name)
 
-  if test_extra_suites.contains('slow')
-    test_timeout = 90
-  endif
+    if test_extra_suites.contains('slow')
+      test_timeout = 90
+    endif
 
-  test(test_name, test_exe,
-    args: [ '--tap', '-k' ],
-    protocol: 'tap',
-    timeout: test_timeout,
-    env: test_env,
-    suite: ['gtk'] + test_extra_suites,
-    should_fail: expect_fail,
-  )
-endforeach
+    test(test_name, test_exe,
+      args: [ '--tap', '-k' ],
+      protocol: 'tap',
+      timeout: test_timeout,
+      env: test_env,
+      suite: ['gtk'] + test_extra_suites,
+      should_fail: expect_fail,
+    )
+  endforeach
+endif
 
 # FIXME: if objc autotestkeywords_CPPFLAGS += -DHAVE_OBJC=1 -x objective-c++
 if add_languages('cpp', required: false, native: false)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]