From ebb6c56f6719cfd06c7e738559fca9d2f9cb1012 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 17 Dec 2018 13:26:07 -0200 Subject: [PATCH] Add Meson support for installed tests This is the last remaining feature necessary to achieve parity with the Autotools build. A few changes were made to the install locations of the tests, in order to better acomodate them in Meson: * Tests are now installed under a versioned folder (e.g. /usr/share/installed-tests/mutter-4) * The mutter-cogl.test file is now generated from an .in file, instead of a series of $(echo)s from within Makefile. Notice that those tests need very controlled environments to run correctly. Mutter installed tests, for example, will failed when running under a regular session due to D-Bus failing to acquire the ScreenCast and/or RemoteScreen names. --- cogl/tests/conform/meson.build | 21 ++++++++++++++++-- cogl/tests/conform/mutter-cogl.test.in | 4 ++++ cogl/tests/meson.build | 12 ++++++++++- meson.build | 7 ++++++ meson_options.txt | 6 ++++++ src/tests/meson.build | 30 ++++++++++++++++++++++---- src/tests/mutter-all.test.in | 2 +- 7 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 cogl/tests/conform/mutter-cogl.test.in diff --git a/cogl/tests/conform/meson.build b/cogl/tests/conform/meson.build index 4427851b7..43abc0b98 100644 --- a/cogl/tests/conform/meson.build +++ b/cogl/tests/conform/meson.build @@ -69,6 +69,20 @@ cogl_test_conformance_includes = [ cogl_test_fixtures_includepath, ] +if have_installed_tests + cogl_installed_tests_cdata = configuration_data() + cogl_installed_tests_cdata.set('libexecdir', libexecdir) + cogl_installed_tests_cdata.set('apiversion', libmutter_api_version) + + configure_file( + input: 'mutter-cogl.test.in', + output: 'mutter-cogl.test', + configuration: cogl_installed_tests_cdata, + install: true, + install_dir: mutter_installed_tests_datadir, + ) +endif + libmutter_cogl_test_conformance = executable('test-conformance', sources: cogl_test_conformance_sources, c_args: cogl_debug_c_args + [ @@ -84,7 +98,9 @@ libmutter_cogl_test_conformance = executable('test-conformance', libmutter_cogl_path_dep, libmutter_cogl_test_fixtures_dep, ], - install: false, + install: have_installed_tests, + install_dir: cogl_installed_tests_libexecdir, + install_rpath: pkglibdir, ) find_unit_tests = find_program('meson/find-conform-unit-tests.sh') @@ -92,7 +108,8 @@ cogl_conform_unit_tests = custom_target('cogl-tests-conform-unit-tests', output: 'unit-tests', input: 'test-conform-main.c', command: [find_unit_tests, '@INPUT@', '@OUTPUT@'], - install: false, + install: have_installed_tests, + install_dir: cogl_installed_tests_libexecdir, ) test('cogl/conform', cogl_run_tests, diff --git a/cogl/tests/conform/mutter-cogl.test.in b/cogl/tests/conform/mutter-cogl.test.in new file mode 100644 index 000000000..d7c85ede2 --- /dev/null +++ b/cogl/tests/conform/mutter-cogl.test.in @@ -0,0 +1,4 @@ +[Test] +Type=session +TestEnvironment=COGL_TEST_VERBOSE=1 +Exec=sh -c "cd @libexecdir@/installed-tests/mutter-@apiversion@/cogl/conform; ./run-tests.sh ./config.env ./test-conformance ./unit-tests" diff --git a/cogl/tests/meson.build b/cogl/tests/meson.build index e5b85bbfc..784bd7d26 100644 --- a/cogl/tests/meson.build +++ b/cogl/tests/meson.build @@ -4,10 +4,20 @@ cdata = configuration_data() cdata.set('HAVE_GL', have_gl.to_int()) cdata.set('HAVE_GLES2', have_gles2.to_int()) +cogl_installed_tests_libexecdir = join_paths( + mutter_installed_tests_libexecdir, 'cogl', 'conform') + +if have_installed_tests + install_data('run-tests.sh', install_dir: cogl_installed_tests_libexecdir) +endif + cogl_config_env = configure_file( input: 'config.env.in', output: 'config.env', - configuration: cdata) + configuration: cdata, + install: have_installed_tests, + install_dir: cogl_installed_tests_libexecdir, +) subdir('conform') subdir('unit') diff --git a/meson.build b/meson.build index 9c6350c6b..48a1fa43d 100644 --- a/meson.build +++ b/meson.build @@ -73,6 +73,12 @@ builddir = meson.current_build_dir() libmutter_name = 'mutter-' + libmutter_api_version +mutter_installed_tests_datadir = join_paths( + datadir, 'installed-tests', libmutter_name) + +mutter_installed_tests_libexecdir = join_paths( + libexecdir, 'installed-tests', libmutter_name) + m_dep = cc.find_library('m', required: true) x11_dep = dependency('x11') gtk3_dep = dependency('gtk+-3.0', version: gtk3_req) @@ -239,6 +245,7 @@ endif have_cogl_tests = get_option('cogl_tests') have_clutter_tests = get_option('clutter_tests') +have_installed_tests = get_option('installed_tests') have_tests = get_option('tests') if have_tests diff --git a/meson_options.txt b/meson_options.txt index a0924faf1..7626661d1 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -123,6 +123,12 @@ option('tests', description: 'Enable mutter tests' ) +option('installed_tests', + type: 'boolean', + value: true, + description: 'Enable mutter installed tests' +) + option('verbose', type: 'boolean', value: true, diff --git a/src/tests/meson.build b/src/tests/meson.build index 90620ab4a..7a4e4dc1e 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -10,6 +10,24 @@ tests_deps = [ libmutter_clutter_dep, ] +if have_installed_tests + stacking_files_datadir = join_paths(pkgdatadir, 'tests') + + installed_tests_cdata = configuration_data() + installed_tests_cdata.set('libexecdir', libexecdir) + installed_tests_cdata.set('apiversion', libmutter_api_version) + + configure_file( + input: 'mutter-all.test.in', + output: 'mutter-all.test', + configuration: installed_tests_cdata, + install: true, + install_dir: mutter_installed_tests_datadir, + ) + + install_subdir('stacking', install_dir: stacking_files_datadir) +endif + test_env = environment() test_env.set('G_TEST_SRCDIR', join_paths(top_srcdir, 'src')) test_env.set('G_TEST_BUILDDIR', builddir) @@ -24,7 +42,8 @@ test_client = executable('mutter-test-client', gio_unix_dep, xext_dep, ], - install: false, + install: have_installed_tests, + install_dir: mutter_installed_tests_libexecdir, ) test_runner = executable('mutter-test-runner', @@ -36,7 +55,8 @@ test_runner = executable('mutter-test-runner', include_directories: tests_includepath, c_args: tests_c_args, dependencies: [tests_deps], - install: false, + install: have_installed_tests, + install_dir: mutter_installed_tests_libexecdir, ) unit_tests = executable('mutter-test-unit-tests', @@ -62,7 +82,8 @@ unit_tests = executable('mutter-test-unit-tests', include_directories: tests_includepath, c_args: tests_c_args, dependencies: [tests_deps], - install: false, + install: have_installed_tests, + install_dir: mutter_installed_tests_libexecdir, ) headless_start_test = executable('mutter-headless-start-test', @@ -78,7 +99,8 @@ headless_start_test = executable('mutter-headless-start-test', include_directories: tests_includepath, c_args: tests_c_args, dependencies: [tests_deps], - install: false, + install: have_installed_tests, + install_dir: mutter_installed_tests_libexecdir, ) stacking_tests = files([ diff --git a/src/tests/mutter-all.test.in b/src/tests/mutter-all.test.in index 679468a6e..3078ff67e 100644 --- a/src/tests/mutter-all.test.in +++ b/src/tests/mutter-all.test.in @@ -1,5 +1,5 @@ [Test] Description=All Mutter tests -Exec=@libexecdir@/installed-tests/mutter/mutter-test-runner --all +Exec=@libexecdir@/installed-tests/mutter-@apiversion@/mutter-test-runner --all Type=session Output=TAP