diff options
author | Simon McVittie <smcv@debian.org> | 2019-08-28 11:40:07 +0100 |
---|---|---|
committer | Claudio Saavedra <csaavedra@igalia.com> | 2019-08-29 11:36:51 +0000 |
commit | 6b03d433a4f008575c0477287096109f5b238cc5 (patch) | |
tree | 4435f561946dc4be9e76418bcf5e03ae33e1614f | |
parent | 2c4244279fa8b7b7843de08201fafeda9bce6ec7 (diff) | |
download | libsoup-6b03d433a4f008575c0477287096109f5b238cc5.tar.gz |
Optionally install installed-tests
This was supported in the old Autotools build system, but was lost
in the move to Meson.
Signed-off-by: Simon McVittie <smcv@debian.org>
Fixes: https://gitlab.gnome.org/GNOME/libsoup/issues/163
-rw-r--r-- | meson_options.txt | 6 | ||||
-rw-r--r-- | tests/meson.build | 78 | ||||
-rw-r--r-- | tests/template-tap.test.in | 4 |
3 files changed, 82 insertions, 6 deletions
diff --git a/meson_options.txt b/meson_options.txt index 4f14e378..12b1aae6 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -64,3 +64,9 @@ option('tests', value: true, description: 'Enable unit tests compilation' ) + +option('installed_tests', + type: 'boolean', + value: false, + description: 'Install tests for as-installed testing' +) diff --git a/tests/meson.build b/tests/meson.build index e6742b45..e755367b 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,16 +1,27 @@ test_utils_name = 'test-utils' +installed_tests_metadir = join_paths(get_option('datadir'), 'installed-tests', libsoup_api_name) +installed_tests_execdir = join_paths(get_option('libexecdir'), 'installed-tests', libsoup_api_name) +installed_tests_enabled = get_option('installed_tests') +installed_tests_template_tap = files('template-tap.test.in') +abs_installed_tests_execdir = join_paths(prefix, installed_tests_execdir) if cc.get_id() == 'msvc' test_utils = static_library(test_utils_name, test_utils_name + '.c', dependencies : libsoup_dep) else test_utils = library(test_utils_name, test_utils_name + '.c', - dependencies : libsoup_dep) + dependencies : libsoup_dep, + install : installed_tests_enabled, + install_dir : installed_tests_execdir, + ) endif test_resources = gnome.compile_resources('soup-tests', 'soup-tests.gresource.xml', - gresource_bundle : true) + gresource_bundle : true, + install : installed_tests_enabled, + install_dir : installed_tests_execdir, +) # ['name', is_parallel, extra_deps] tests = [ @@ -50,6 +61,15 @@ if brotlidec_dep.found() tests += [ ['brotli-decompressor', true, []], ] + + if installed_tests_enabled + install_data( + 'brotli-data/compressed.br', + 'brotli-data/corrupt.br', + 'brotli-data/uncompressed.txt', + install_dir : join_paths(installed_tests_execdir, 'brotli-data'), + ) + endif endif if have_apache @@ -63,7 +83,10 @@ if have_apache configure_file(output : 'httpd.conf', input : 'httpd.conf.in', - configuration : cdata) + configuration : cdata, + install : installed_tests_enabled, + install_dir : installed_tests_execdir, + ) configure_file(input : 'htdigest', output : 'htdigest', @@ -80,12 +103,26 @@ if have_apache configure_file(input : 'test-key.pem', output : 'test-key.pem', copy : true) + + if installed_tests_enabled + install_data( + 'index.txt', + 'test-cert.pem', + 'test-key.pem', + 'htdigest', + 'htpasswd', + install_dir : installed_tests_execdir, + ) + endif endif if have_php configure_file(output : 'php.ini', input : 'php.ini.in', - configuration : cdata) + configuration : cdata, + install : installed_tests_enabled, + install_dir : installed_tests_execdir, + ) endif if have_php_xmlrpc @@ -99,6 +136,13 @@ if have_php_xmlrpc configure_file(input : 'xmlrpc-server.php', output : 'xmlrpc-server.php', copy : true) + + if installed_tests_enabled + install_data( + 'xmlrpc-server.php', + install_dir : installed_tests_execdir, + ) + endif endif env = environment() @@ -113,15 +157,37 @@ env.set('MALLOC_PERTURB_', '') foreach test: tests test_name = '@0@-test'.format(test[0]) + + if installed_tests_enabled + test_conf = configuration_data() + test_conf.set('installed_tests_dir', abs_installed_tests_execdir) + test_conf.set('program', test_name) + test_conf.set('env', '') + configure_file( + input : installed_tests_template_tap, + output : test_name + '.test', + install_dir : installed_tests_metadir, + configuration : test_conf, + ) + endif + test_deps = [ libsoup_dep ] + test[2] test_target = executable(test_name, sources : [ test_name + '.c', test_resources ], link_with : test_utils, - dependencies : test_deps) + dependencies : test_deps, + install : installed_tests_enabled, + install_dir : installed_tests_execdir, + install_rpath : abs_installed_tests_execdir, + ) # Increase the timeout as on some architectures the tests could be slower # than the default 30 seconds. test(test_name, test_target, env : env, is_parallel : test[1], timeout : 60) endforeach executable('ntlm-test-helper', 'ntlm-test-helper.c', - dependencies : libsoup_dep) + dependencies : libsoup_dep, + install : installed_tests_enabled, + install_dir : installed_tests_execdir, + install_rpath : abs_installed_tests_execdir, +) diff --git a/tests/template-tap.test.in b/tests/template-tap.test.in new file mode 100644 index 00000000..30cd1668 --- /dev/null +++ b/tests/template-tap.test.in @@ -0,0 +1,4 @@ +[Test] +Type=session +Exec=@env@@installed_tests_dir@/@program@ --tap +Output=TAP |