gmodule/tests/meson: Make tests depending on loaded libraries and modules

This commit is contained in:
Marco Trevisan (Treviño) 2022-10-25 17:16:22 +02:00
parent 82fc49fa10
commit eef2b0b39e

View File

@ -1,17 +1,5 @@
gmodule_tests = {
'max-version' : {'install': false},
'module-test-library' : {
'export_dynamic' : true,
'source': 'module-test.c',
'c_args': ['-DMODULE_TYPE="library"'],
'can_fail': glib_build_static and host_system == 'windows',
},
'module-test-plugin' : {
'export_dynamic' : true,
'source': 'module-test.c',
'c_args': ['-DMODULE_TYPE="plugin"'],
'can_fail': glib_build_static and host_system == 'windows',
},
}
if have_cxx
@ -40,16 +28,20 @@ if ['darwin', 'ios'].contains(host_machine.system())
module_suffix = 'so'
endif
gmodule_test_modules = []
gmodule_test_libraries = []
if glib_build_shared
foreach module : ['moduletestplugin_a', 'moduletestplugin_b']
shared_module(module + '_plugin', 'lib@0@.c'.format(module),
gmodule_test_modules += shared_module(module + '_plugin',
'lib@0@.c'.format(module),
dependencies : [libglib_dep, libgmodule_dep],
install_dir : installed_tests_execdir,
install_tag : 'tests',
install : installed_tests_enabled,
name_suffix : module_suffix
)
shared_library(module + '_library', 'lib@0@.c'.format(module),
gmodule_test_libraries += shared_library(module + '_library',
'lib@0@.c'.format(module),
dependencies : [libglib_dep, libgmodule_dep],
install_dir : installed_tests_execdir,
install_tag : 'tests',
@ -59,6 +51,23 @@ if glib_build_shared
endforeach
endif
gmodule_tests += {
'module-test-library' : {
'export_dynamic' : true,
'source': 'module-test.c',
'depends': gmodule_test_libraries,
'c_args': ['-DMODULE_TYPE="library"'],
'can_fail': glib_build_static_only,
},
'module-test-plugin' : {
'export_dynamic' : true,
'source': 'module-test.c',
'depends': gmodule_test_modules,
'c_args': ['-DMODULE_TYPE="plugin"'],
'can_fail': glib_build_static_only,
},
}
test_env = environment()
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
@ -98,10 +107,17 @@ foreach test_name, extra_args : gmodule_tests
suite = ['gmodule'] + extra_args.get('suite', [])
timeout = suite.contains('slow') ? test_timeout_slow : test_timeout
depends = [extra_args.get('depends', [])]
if extra_args.get('can_fail', false)
suite += 'failing'
endif
test(test_name, exe, env : test_env, timeout : timeout, suite : suite)
test(test_name,
exe,
depends : depends,
env : test_env,
timeout : timeout,
suite : suite,
)
endforeach