diff --git a/gio/tests/meson.build b/gio/tests/meson.build index e4b4959cb9ee7888f58e9e5545cf936a8abe29c5..a1b41872dea33b1f6eaeb9020616be232aa9aea7 100644 --- a/gio/tests/meson.build +++ b/gio/tests/meson.build @@ -140,11 +140,16 @@ if host_machine.system() != 'windows' 'slow-connect-preload.c', name_prefix : '', dependencies: cc.find_library('dl'), + install_dir : installed_tests_execdir, + install: installed_tests_enabled, ) ], 'env' : { 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(meson.current_build_dir()) }, + 'installed_tests_env' : { + 'LD_PRELOAD': '@0@/slow-connect-preload.so'.format(installed_tests_execdir), + }, 'suite': ['flaky'], }, 'gschema-compile' : {'install' : false}, @@ -593,11 +598,21 @@ foreach test_name, extra_args : gio_tests source = extra_args.get('source', test_name + '.c') extra_sources = extra_args.get('extra_sources', []) install = installed_tests_enabled and extra_args.get('install', true) + installed_tests_env = extra_args.get('installed_tests_env', {}) if install test_conf = configuration_data() test_conf.set('installed_tests_dir', installed_tests_execdir) test_conf.set('program', test_name) + test_env_override = '' + if installed_tests_env != {} + envs = [] + foreach var, value : installed_tests_env + envs += '@0@=@1@'.format(var, value) + endforeach + test_env_override = '@0@ @1@ '.format(env_program.path(), ' '.join(envs)) + endif + test_conf.set('env', test_env_override) configure_file( input: installed_tests_template_tap, output: test_name + '.test', diff --git a/glib/tests/meson.build b/glib/tests/meson.build index 814ddbe01f5053d4c8d216da8744ce92adadb559..d54fc41fac655c7dd7c51682355fc50d55765b0a 100644 --- a/glib/tests/meson.build +++ b/glib/tests/meson.build @@ -183,6 +183,7 @@ foreach test_name, extra_args : glib_tests test_conf = configuration_data() test_conf.set('installed_tests_dir', installed_tests_execdir) test_conf.set('program', test_name) + test_conf.set('env', '') configure_file( input: installed_tests_template_tap, output: test_name + '.test', diff --git a/gobject/tests/meson.build b/gobject/tests/meson.build index 44d4588d1868ed7a0539f8a8260c7393d7f0a56d..b7fb2364cdb6918d52fd4dc8dd8f34c490981f07 100644 --- a/gobject/tests/meson.build +++ b/gobject/tests/meson.build @@ -77,6 +77,7 @@ foreach test_name, extra_args : gobject_tests test_conf = configuration_data() test_conf.set('installed_tests_dir', installed_tests_execdir) test_conf.set('program', test_name) + test_conf.set('env', '') configure_file( input: installed_tests_template_tap, output: test_name + '.test', diff --git a/meson.build b/meson.build index 98907ca1687ea86a3ab8362f06eab48fe9a7cf69..ad8c4cdd829eb8f6aa5a65a755ceedd367964ba5 100644 --- a/meson.build +++ b/meson.build @@ -1893,6 +1893,9 @@ endif have_bash = find_program('bash', required : false).found() # For completion scripts have_sh = find_program('sh', required : false).found() # For glib-gettextize +# Some installed tests require a custom environment +env_program = find_program('env', required: installed_tests_enabled) + # FIXME: How to detect Solaris? https://github.com/mesonbuild/meson/issues/1578 if host_system == 'sunos' glib_conf.set('_XOPEN_SOURCE_EXTENDED', 1) diff --git a/template-tap.test.in b/template-tap.test.in index 6adf73f0369d5ccfa4a5b2777fd73756569d330b..30cd1668612ebd0e1955ad32ee75a37410e20257 100644 --- a/template-tap.test.in +++ b/template-tap.test.in @@ -1,4 +1,4 @@ [Test] Type=session -Exec=@installed_tests_dir@/@program@ --tap +Exec=@env@@installed_tests_dir@/@program@ --tap Output=TAP diff --git a/tests/gobject/meson.build b/tests/gobject/meson.build index 4b1c690857a0f81bd10a01ec53d5ee81e27c4b43..eabaea5b2c62190bb9af38f2f6e59aa39db93954 100644 --- a/tests/gobject/meson.build +++ b/tests/gobject/meson.build @@ -66,6 +66,7 @@ foreach test_name, extra_args : gobject_tests test_conf = configuration_data() test_conf.set('installed_tests_dir', installed_tests_execdir) test_conf.set('program', test_name) + test_conf.set('env', '') configure_file( input: template, output: test_name + '.test', diff --git a/tests/meson.build b/tests/meson.build index 1d53db288f54a0c4aa6a03dcc1549f2598376b93..11075dd8ebb8edefe9544dcdc32d4f90ae1a8df5 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -109,6 +109,7 @@ foreach test_name, extra_args : tests test_conf = configuration_data() test_conf.set('installed_tests_dir', installed_tests_execdir) test_conf.set('program', test_name) + test_conf.set('env', '') configure_file( input: template, output: test_name + '.test', diff --git a/tests/refcount/meson.build b/tests/refcount/meson.build index 22b9655d7721fd15bdccfa1f28a8802eef35dd08..e17e38b454f21fbac833d3a6015a713afc8fb3d9 100644 --- a/tests/refcount/meson.build +++ b/tests/refcount/meson.build @@ -36,6 +36,7 @@ foreach test_name, extra_args : refcount_tests test_conf = configuration_data() test_conf.set('installed_tests_dir', installed_tests_execdir) test_conf.set('program', test_name) + test_conf.set('env', '') configure_file( input: installed_tests_template, output: test_name + '.test',