summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-05-11 10:31:25 +0100
committerSimon McVittie <smcv@debian.org>2022-05-11 10:51:07 +0100
commite1bc1a79fed81fb804a89837d9f32dcc9cd09c64 (patch)
tree0f38fe1905c200ecbaeba1e1f1b7adb73af74874
parent190fec1dcebe44f6650cde648a696564209341a4 (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.txt6
-rw-r--r--tests/Makefile.am.inc1
-rw-r--r--tests/meson.build18
-rw-r--r--tests/tap.test.in4
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