Commit 6b03d433 authored by Simon McVittie's avatar Simon McVittie Committed by Claudio Saavedra

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's avatarSimon McVittie <smcv@debian.org>
Fixes: #163
parent 2c424427
Pipeline #109394 passed with stage
in 1 minute and 4 seconds
......@@ -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'
)
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,
)
[Test]
Type=session
Exec=@env@@installed_tests_dir@/@program@ --tap
Output=TAP
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment