diff options
author | Simon McVittie <smcv@collabora.com> | 2022-05-11 10:31:25 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2022-11-12 17:29:46 +0000 |
commit | 04f0ac26853fb4ce6166d60002292ac32934c57f (patch) | |
tree | 6b35a842fdf859fcbb55d9170e4b5911063d6563 | |
parent | 56f2a07130b316539a80ff4c5076a77de94f0bab (diff) |
meson: Optionally install tests for "as-installed" testing
This is used in the Debian packaging via ginsttest-runner and the
autopkgtest framework. Previously, it was supported by the Autotools
build system but not by the Meson build system.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Forwarded: https://github.com/flatpak/xdg-dbus-proxy/pull/43
Gbp-Pq: Name meson-Optionally-install-tests-for-as-installed-testing.patch
-rw-r--r-- | meson_options.txt | 6 | ||||
-rw-r--r-- | tests/Makefile.am.inc | 1 | ||||
-rw-r--r-- | tests/meson.build | 18 | ||||
-rw-r--r-- | tests/tap.test.in | 4 |
4 files changed, 29 insertions, 0 deletions
diff --git a/meson_options.txt b/meson_options.txt index 30dc257..a8652f4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,10 @@ option( + 'installed_tests', + type : 'boolean', + description : 'Build and install "as-installed" tests', + value : 'false', +) +option( 'man', type : 'feature', description : 'generate man pages', diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc index 8ee80b1..649ae12 100644 --- a/tests/Makefile.am.inc +++ b/tests/Makefile.am.inc @@ -13,6 +13,7 @@ test_proxy_SOURCES = tests/test-proxy.c test_proxy_LDADD = $(COMMON_LIBS) EXTRA_DIST += tests/meson.build +EXTRA_DIST += tests/tap.test.in EXTRA_DIST += tests/use-as-subproject/README EXTRA_DIST += tests/use-as-subproject/config.h EXTRA_DIST += tests/use-as-subproject/dummy-config.h.in diff --git a/tests/meson.build b/tests/meson.build index 6345c1d..5aebdb4 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,3 +1,7 @@ +enable_installed_tests = get_option('installed_tests') and not meson.is_subproject() +installed_testdir = get_option('libexecdir') / 'installed-tests' / meson.project_name() +installed_tests_metadir = get_option('datadir') / 'installed-tests' / meson.project_name() + test_programs = [ [ 'test-proxy', @@ -6,6 +10,8 @@ test_programs = [ 'test-proxy.c', dependencies : common_deps, include_directories : common_include_directories, + install : enable_installed_tests, + install_dir : installed_testdir, ), ], ] @@ -32,4 +38,16 @@ foreach pair : test_programs env : test_env, ) endif + + if enable_installed_tests + configure_file( + input : 'tap.test.in', + output : name + '.test', + configuration : { + 'basename' : name, + 'installed_testdir' : get_option('prefix') / installed_testdir, + }, + install_dir : installed_tests_metadir, + ) + endif endforeach diff --git a/tests/tap.test.in b/tests/tap.test.in new file mode 100644 index 0000000..6a3aeb2 --- /dev/null +++ b/tests/tap.test.in @@ -0,0 +1,4 @@ +[Test] +Type=session +Exec=@installed_testdir@/@basename@ --tap +Output=TAP |