Skip to content

Commit

Permalink
Merge pull request #43 from smcv/installed-tests
Browse files Browse the repository at this point in the history
meson: Optionally install tests for "as-installed" testing
  • Loading branch information
smcv authored Dec 8, 2022
2 parents 6bfe8c3 + 4c3c2eb commit d3c1faa
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
option(
'installed_tests',
type : 'boolean',
description : 'Build and install "as-installed" tests',
value : 'false',
)
option(
'man',
type : 'feature',
Expand Down
1 change: 1 addition & 0 deletions tests/Makefile.am.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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,
),
],
]
Expand All @@ -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
4 changes: 4 additions & 0 deletions tests/tap.test.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Test]
Type=session
Exec=@installed_testdir@/@basename@ --tap
Output=TAP

0 comments on commit d3c1faa

Please sign in to comment.