[rhythmbox/mesonjunk: 7/9] build: convert tests option to a feature




commit 1838ee438cea53234c9ddc51b8a24fa342cb2bfc
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sun May 29 16:26:06 2022 +1000

    build: convert tests option to a feature

 .gitlab-ci.yml           |   2 +-
 meson.build              |  17 +++-----
 meson_options.txt        |   2 +-
 plugins/ipod/meson.build |   2 +-
 tests/meson.build        | 106 +++++++++++++++++++++++------------------------
 5 files changed, 61 insertions(+), 68 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 63a305855..c37abc96e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -56,7 +56,7 @@ variables:
     -Dsample-plugins=true
     -Dgtk_doc=true
     -Dhelp=true
-    -Dtests=true
+    -Dtests=enabled
 
 before_script:
   - export DEBIAN_FRONTEND=noninteractive
diff --git a/meson.build b/meson.build
index dfc2e369d..1f44e0ae7 100644
--- a/meson.build
+++ b/meson.build
@@ -70,6 +70,8 @@ pango = dependency('pango', required: true)
 tdb = dependency('tdb', version: '>= 1.2.6', required: true)
 totem_plparser = dependency('totem-plparser', version: '>= 3.2.0', required: true)
 
+check = dependency('check', required: get_option('tests'))
+
 use_gudev = false
 gudev = dependency('gudev-1.0', version: '>= 143', required: get_option('gudev'))
 if gudev.found()
@@ -255,15 +257,6 @@ if grilo.found()
   plugins += 'grilo'
 endif
 
-enable_check = false
-if get_option('tests') == true
-  check = dependency('check', required: false)
-
-  if check.found()
-    enable_check = true
-  endif
-endif
-
 pkg.generate(
   name: 'rhythmbox',
   description: 'plugin API for rhythmbox',
@@ -284,7 +277,7 @@ configure_file(input : 'config.h.meson',
   output : 'config.h',
 configuration : cdata)
 
-summary({'Tests': enable_check,
+summary({'Tests': check.found(),
          'Help': get_option('help'),
          'API documentation': get_option('gtk_doc'),
         },
@@ -345,7 +338,9 @@ endif
 subdir('remote')
 
 subdir('bindings')
-subdir('tests')
+if check.found()
+  subdir('tests')
+endif
 subdir('po')
 if get_option('gtk_doc')
   subdir('doc/reference')
diff --git a/meson_options.txt b/meson_options.txt
index 2e9dcd834..256c02056 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -29,5 +29,5 @@ option('help', type: 'boolean', value: 'true',
        description: 'Install user documentation')
 option('gtk_doc', type: 'boolean', value: 'false',
        description: 'Use gtk-doc to build documentation')
-option('tests', type: 'boolean', value: 'false',
+option('tests', type: 'feature', value: 'auto',
        description: 'Build tests')
diff --git a/plugins/ipod/meson.build b/plugins/ipod/meson.build
index 6c03fa792..f754069d6 100644
--- a/plugins/ipod/meson.build
+++ b/plugins/ipod/meson.build
@@ -29,7 +29,7 @@ ipod_plugin_descriptor = custom_target('ipod-plugin-descriptor',
   install: true,
   install_dir: ipod_plugin_dir)
 
-if enable_check
+if check.found()
     test('test-ipod',
     executable('test-ipod',
       ['test-ipod.c', 'rb-ipod-helpers.c'],
diff --git a/tests/meson.build b/tests/meson.build
index 2eb468282..808b02b8f 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,61 +1,59 @@
-if enable_check
-  test('test-rhythmdb',
-    executable('test-rhythmdb',
-      ['test-rhythmdb.c', 'test-utils.c'],
-      dependencies: [rhythmbox_core_dep, check],
-      c_args: ['-DTEST_DIR="@0@"'.format(meson.current_source_dir())]),
-    depends: gschemas_compiled,
-    env: ['CK_DEFAULT_TIMEOUT=0'],
-  )
+test('test-rhythmdb',
+  executable('test-rhythmdb',
+    ['test-rhythmdb.c', 'test-utils.c'],
+    dependencies: [rhythmbox_core_dep, check],
+    c_args: ['-DTEST_DIR="@0@"'.format(meson.current_source_dir())]),
+  depends: gschemas_compiled,
+  env: ['CK_DEFAULT_TIMEOUT=0'],
+)
 
-  test('test-rhythmdb-query-model',
-    executable('test-rhythmdb-query-model',
-      ['test-rhythmdb-query-model.c', 'test-utils.c'],
-      dependencies: [rhythmbox_core_dep, check]),
-    depends: gschemas_compiled,
-    env: ['CK_DEFAULT_TIMEOUT=0'],
-  )
+test('test-rhythmdb-query-model',
+  executable('test-rhythmdb-query-model',
+    ['test-rhythmdb-query-model.c', 'test-utils.c'],
+    dependencies: [rhythmbox_core_dep, check]),
+  depends: gschemas_compiled,
+  env: ['CK_DEFAULT_TIMEOUT=0'],
+)
 
-  test('test-rhythmdb-property-model',
-    executable('test-rhythmdb-property-model',
-      ['test-rhythmdb-property-model.c', 'test-utils.c'],
-      dependencies: [rhythmbox_core_dep, check]),
-    depends: gschemas_compiled,
-    env: ['CK_DEFAULT_TIMEOUT=0'],
-  )
+test('test-rhythmdb-property-model',
+  executable('test-rhythmdb-property-model',
+    ['test-rhythmdb-property-model.c', 'test-utils.c'],
+    dependencies: [rhythmbox_core_dep, check]),
+  depends: gschemas_compiled,
+  env: ['CK_DEFAULT_TIMEOUT=0'],
+)
 
-  test('test-file-helpers',
-    executable('test-file-helpers',
-      ['test-file-helpers.c', 'test-utils.c'],
-      dependencies: [rhythmbox_core_dep, check]),
-    env: ['CK_DEFAULT_TIMEOUT=0'],
-  )
+test('test-file-helpers',
+  executable('test-file-helpers',
+    ['test-file-helpers.c', 'test-utils.c'],
+    dependencies: [rhythmbox_core_dep, check]),
+  env: ['CK_DEFAULT_TIMEOUT=0'],
+)
 
-  test('test-rb-lib',
-    executable('test-rb-lib',
-      ['test-rb-lib.c', 'test-utils.c'],
-      dependencies: [rhythmbox_core_dep, check]),
-    env: ['CK_DEFAULT_TIMEOUT=0'],
-  )
+test('test-rb-lib',
+  executable('test-rb-lib',
+    ['test-rb-lib.c', 'test-utils.c'],
+    dependencies: [rhythmbox_core_dep, check]),
+  env: ['CK_DEFAULT_TIMEOUT=0'],
+)
 
-  test('test-audioscrobbler',
-    executable('test-audioscrobbler',
-      ['test-audioscrobbler.c', 'test-utils.c'],
-      dependencies: [rhythmbox_core_dep, audioscrobbler_test_dep, check]),
-    env: ['CK_DEFAULT_TIMEOUT=0'],
-  )
+test('test-audioscrobbler',
+  executable('test-audioscrobbler',
+    ['test-audioscrobbler.c', 'test-utils.c'],
+    dependencies: [rhythmbox_core_dep, audioscrobbler_test_dep, check]),
+  env: ['CK_DEFAULT_TIMEOUT=0'],
+)
 
-  test_widgets_resources = gnome.compile_resources('test-widgets-resources', 'test-widgets.gresource.xml',
-    source_dir: ['../data'])
-  test('test-widgets',
-    executable('test-widgets',
-      ['test-widgets.c', 'test-utils.c', test_widgets_resources],
-      dependencies: [rhythmbox_core_dep, check]),
-    depends: gschemas_compiled,
-    env: ['CK_DEFAULT_TIMEOUT=0'],
-  )
+test_widgets_resources = gnome.compile_resources('test-widgets-resources', 'test-widgets.gresource.xml',
+  source_dir: ['../data'])
+test('test-widgets',
+  executable('test-widgets',
+    ['test-widgets.c', 'test-utils.c', test_widgets_resources],
+    dependencies: [rhythmbox_core_dep, check]),
+  depends: gschemas_compiled,
+  env: ['CK_DEFAULT_TIMEOUT=0'],
+)
 
-  executable('bench-rhythmdb-load',
-    'bench-rhythmdb-load.c',
-    dependencies: [rhythmbox_core_dep])
-endif
+executable('bench-rhythmdb-load',
+  'bench-rhythmdb-load.c',
+  dependencies: [rhythmbox_core_dep])


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