gplugin/gplugin

Add runtime dependencies to tests

8 months ago, Elliott Sales de Andrade
b493e1ee4fbd
Parents 56abba6da605
Children 9fa5d9e1fc11
Add runtime dependencies to tests

`meson test` only builds what's required to run a test. If you start with a clean build directory (or run `ninja clean`), then about half the tests fail because the required plugins or even the loaders themselves have not yet been built.

This adds the proper dependencies so that all requirements are built before testing.

The name of the macro used to pass through the build directory has also been made consistent, so that it could be automatically generated.

Testing Done:
`ninja clean` and then `meson test`, and all tests now pass.
Also `ninja clean` and `meson test "test name"` for all test names, and each individual test passes.

Reviewed at https://reviews.imfreedom.org/r/2662/
--- a/gplugin/tests/auto-load-fail/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/auto-load-fail/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -1,3 +1,5 @@
-shared_library('auto-load-fail', 'auto-load-fail.c',
+plugin = shared_library('auto-load-fail', 'auto-load-fail.c',
name_prefix : '',
dependencies : [gplugin_dep, GLIB])
+
+all_native_test_plugins += {'auto-load-fail': plugin}
--- a/gplugin/tests/auto-load-pass/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/auto-load-pass/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -1,3 +1,5 @@
-shared_library('auto-load-pass', 'auto-load-pass.c',
+plugin = shared_library('auto-load-pass', 'auto-load-pass.c',
name_prefix : '',
dependencies : [gplugin_dep, GLIB])
+
+all_native_test_plugins += {'auto-load-pass': plugin}
--- a/gplugin/tests/bad-plugins/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/bad-plugins/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -1,3 +1,5 @@
-shared_library('query-error', 'query-error.c',
+plugin = shared_library('query-error', 'query-error.c',
name_prefix : '',
dependencies : [gplugin_dep, GLIB])
+
+all_native_test_plugins += {'bad-plugins': plugin}
--- a/gplugin/tests/bind-global/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/bind-global/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -1,3 +1,5 @@
-shared_library('bind-global', 'bind-global.c',
+plugin = shared_library('bind-global', 'bind-global.c',
name_prefix : '',
dependencies : [gplugin_dep, GLIB])
+
+all_native_test_plugins += {'bind-global': plugin}
--- a/gplugin/tests/dynamic-type/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/dynamic-type/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -5,8 +5,10 @@
name_prefix : '',
dependencies : [gplugin_dep, GLIB])
-shared_module('dynamic-type-user', 'dynamic-type-user.c',
+dynamic_type_user = shared_module('dynamic-type-user', 'dynamic-type-user.c',
name_prefix : '',
dependencies : [gplugin_dep, GLIB])
+all_native_test_plugins += {'dynamic-type': [dynamic_type_provider, dynamic_type_user]}
+
endif
--- a/gplugin/tests/id-collision/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/id-collision/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -1,7 +1,9 @@
-shared_library('id-collision1', 'id-collision1.c',
+plugin1 = shared_library('id-collision1', 'id-collision1.c',
name_prefix : '',
dependencies : [gplugin_dep, GLIB])
-shared_library('id-collision2', 'id-collision2.c',
+plugin2 = shared_library('id-collision2', 'id-collision2.c',
name_prefix : '',
dependencies : [gplugin_dep, GLIB])
+
+all_native_test_plugins += {'id-collision': [plugin1, plugin2]}
--- a/gplugin/tests/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -1,3 +1,5 @@
+all_native_test_plugins = {}
+
###############################################################################
# Subdirectories
###############################################################################
@@ -20,56 +22,31 @@
#######################################
current_build_dir = meson.current_build_dir()
TESTS = {
- # name -> c_args
- 'core': [
- f'-DTEST_DIR="@current_build_dir@/plugins/"',
- f'-DTEST_ID_DIR="@current_build_dir@/id-collision/"',
- ],
- 'auto-load': [
- f'-DTEST_DIR="@current_build_dir@/plugins/"',
- f'-DTEST_AUTO_LOAD_PASS_DIR="@current_build_dir@/auto-load-pass"',
- f'-DTEST_AUTO_LOAD_FAIL_DIR="@current_build_dir@/auto-load-fail"',
- ],
- 'bind-global': [
- f'-DTEST_BIND_GLOBAL_DIR="@current_build_dir@/bind-global/"',
- f'-DTEST_BAD_DIR="@current_build_dir@/bad-plugins/"',
- f'-DTEST_ID_DIR="@current_build_dir@/id-collision/"',
- ],
- 'find-plugins': [
- f'-DTEST_DIR="@current_build_dir@/plugins/"',
- ],
- 'id-collision': [
- f'-DTEST_ID_DIR="@current_build_dir@/id-collision/"',
- ],
+ # name -> [required plugin names]
+ 'core': ['plugins', 'id-collision'],
+ 'auto-load': ['plugins', 'auto-load-pass', 'auto-load-fail'],
+ 'bind-global': ['bad-plugins', 'bind-global', 'id-collision'],
+ 'find-plugins': ['plugins'],
+ 'id-collision': ['id-collision'],
'id-normalize': [],
'loader': [],
'loader-registration': [],
- 'newest-version': [
- f'-DTEST_DIR="@current_build_dir@/newest-version/"',
- ],
+ 'newest-version': ['newest-version'],
'option-group': [],
'plugin-manager-paths': [],
'plugin-info': [],
- 'signals': [
- f'-DTEST_DIR="@current_build_dir@/plugins/"',
- ],
+ 'signals': ['plugins'],
'source': [],
- 'unresolved-symbol': [
- f'-DPLUGIN_DIR="@current_build_dir@/unresolved-symbol/"',
- ],
+ 'unresolved-symbol': ['unresolved-symbol'],
'version-compare': [],
- 'versioned-dependencies': [
- f'-DTEST_VERSIONED_DEPENDENCY_DIR="@current_build_dir@/versioned-dependencies"',
- ],
+ 'versioned-dependencies': ['versioned-dependencies'],
}
# dynamic-type-provider and dynamic-type-user libs are not built on Windows
# so no need to test them there either
if host_machine.system() != 'windows'
TESTS += {
- 'dynamic-type': [
- f'-DTEST_DYNAMIC_DIR="@current_build_dir@/dynamic-type/"',
- ],
+ 'dynamic-type': ['dynamic-type'],
}
endif
@@ -77,25 +54,39 @@
# Tests
###############################################################################
-foreach prog, c_args : TESTS
+foreach prog, plugins : TESTS
+ c_args = []
+ depends = []
+ foreach name : plugins
+ macro_name = name.underscorify().to_upper()
+ c_args += f'-DTEST_@macro_name@_DIR="@current_build_dir@/@name@"'
+ depends += all_native_test_plugins[name]
+ endforeach
+
e = executable(f'test-@prog@', f'test-@prog@.c',
c_args: c_args,
dependencies: [gplugin_dep, GLIB, GOBJECT])
if prog == 'unresolved-symbol'
continue
endif
- test(prog, e)
+ test(prog, e,
+ depends: depends)
endforeach
#######################################
# Native Loader
#######################################
+c_args = []
+depends = []
+foreach name : ['plugins', 'bad-plugins', 'id-collision']
+ macro_name = name.underscorify().to_upper()
+ c_args += f'-DTEST_@macro_name@_DIR="@current_build_dir@/@name@"'
+ depends += all_native_test_plugins[name]
+endforeach
+
e = executable('test-native-loader', 'test-native-loader.c',
- c_args : [
- f'-DTEST_DIR="@current_build_dir@/plugins/"',
- f'-DTEST_BAD_DIR="@current_build_dir@/bad-plugins/"',
- f'-DTEST_ID_DIR="@current_build_dir@/id-collision/"',
- ],
+ c_args : c_args,
link_with : gplugin_loader_tests,
dependencies : [gplugin_dep, GLIB, GOBJECT])
-test('Native Loader', e)
+test('Native loader', e,
+ depends: depends)
--- a/gplugin/tests/newest-version/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/newest-version/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -8,8 +8,12 @@
'solo-no-version',
'solo-non-semantic',
]
+plugins = []
foreach module : MODULES
- shared_module(module, f'@module@.c',
- name_prefix: '', dependencies : [gplugin_dep, GLIB])
+ plugins += shared_module(module, f'@module@.c',
+ name_prefix: '',
+ dependencies : [gplugin_dep, GLIB])
endforeach
+
+all_native_test_plugins += {'newest-version': plugins}
--- a/gplugin/tests/plugins/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/plugins/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -7,10 +7,14 @@
'unload-failed',
'unload-shutdown',
]
+plugins = []
foreach lib : LIBRARIES
- shared_library(lib, f'@lib@.c',
- name_prefix: '', dependencies : [gplugin_dep, GLIB])
+ plugins += shared_library(lib, f'@lib@.c',
+ name_prefix: '',
+ dependencies : [gplugin_dep, GLIB])
endforeach
+all_native_test_plugins += {'plugins': plugins}
+
subdir('settings')
--- a/gplugin/tests/test-auto-load.c Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/test-auto-load.c Mon Oct 16 22:35:31 2023 -0500
@@ -61,7 +61,7 @@
* but it has to be looked for manually.
*/
gplugin_manager_remove_paths(manager);
- gplugin_manager_append_path(manager, TEST_DIR);
+ gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
gplugin_manager_append_path(manager, TEST_AUTO_LOAD_FAIL_DIR);
gplugin_manager_refresh(manager);
}
--- a/gplugin/tests/test-core.c Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/test-core.c Mon Oct 16 22:35:31 2023 -0500
@@ -92,7 +92,7 @@
gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
manager = gplugin_manager_get_default();
- gplugin_manager_append_path(manager, TEST_DIR);
+ gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
gplugin_manager_refresh(manager);
gplugin_uninit();
@@ -108,8 +108,8 @@
manager = gplugin_manager_get_default();
- gplugin_manager_append_path(manager, TEST_DIR);
- gplugin_manager_append_path(manager, TEST_ID_DIR);
+ gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
+ gplugin_manager_append_path(manager, TEST_ID_COLLISION_DIR);
/* run the first refresh and count everything */
gplugin_manager_refresh(manager);
--- a/gplugin/tests/test-dynamic-type.c Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/test-dynamic-type.c Mon Oct 16 22:35:31 2023 -0500
@@ -35,7 +35,7 @@
GError *error = NULL;
gboolean ret = FALSE;
- gplugin_manager_append_path(manager, TEST_DYNAMIC_DIR);
+ gplugin_manager_append_path(manager, TEST_DYNAMIC_TYPE_DIR);
gplugin_manager_refresh(manager);
provider =
--- a/gplugin/tests/test-find-plugins.c Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/test-find-plugins.c Mon Oct 16 22:35:31 2023 -0500
@@ -89,7 +89,7 @@
manager = gplugin_manager_get_default();
- gplugin_manager_append_path(manager, TEST_DIR);
+ gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
gplugin_manager_refresh(manager);
/* make sure that all the plugins are queried */
--- a/gplugin/tests/test-id-collision.c Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/test-id-collision.c Mon Oct 16 22:35:31 2023 -0500
@@ -34,7 +34,7 @@
manager = gplugin_manager_get_default();
- gplugin_manager_append_path(manager, TEST_ID_DIR);
+ gplugin_manager_append_path(manager, TEST_ID_COLLISION_DIR);
gplugin_manager_refresh(manager);
plugins = gplugin_manager_find_plugins(manager, "gplugin/id-collision");
--- a/gplugin/tests/test-native-loader.c Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/test-native-loader.c Mon Oct 16 22:35:31 2023 -0500
@@ -35,7 +35,7 @@
GError *error = NULL;
/* add the test directory to the plugin manager's search paths */
- gplugin_manager_append_path(manager, TEST_DIR);
+ gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
/* refresh the plugin manager */
gplugin_manager_refresh(manager);
@@ -66,7 +66,7 @@
GPluginPlugin *plugin = NULL;
/* add the test directory to the plugin manager's search paths */
- gplugin_manager_append_path(manager, TEST_BAD_DIR);
+ gplugin_manager_append_path(manager, TEST_BAD_PLUGINS_DIR);
/* refresh the plugin manager */
gplugin_manager_refresh(manager);
@@ -91,7 +91,7 @@
gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
- gplugin_loader_tests_main(NULL, TEST_DIR, "native");
+ gplugin_loader_tests_main(NULL, TEST_PLUGINS_DIR, "native");
g_test_add_func(
"/loaders/native/load/broken_dependent",
--- a/gplugin/tests/test-newest-version.c Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/test-newest-version.c Mon Oct 16 22:35:31 2023 -0500
@@ -29,7 +29,7 @@
GPluginPlugin *plugin = NULL;
GPluginPluginInfo *info = NULL;
- gplugin_manager_append_path(manager, TEST_DIR);
+ gplugin_manager_append_path(manager, TEST_NEWEST_VERSION_DIR);
gplugin_manager_refresh(manager);
plugin = gplugin_manager_find_plugin_with_newest_version(manager, id);
--- a/gplugin/tests/test-signals.c Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/test-signals.c Mon Oct 16 22:35:31 2023 -0500
@@ -175,7 +175,7 @@
G_CALLBACK(test_gplugin_manager_signals_normal_unloaded),
&data);
- gplugin_manager_append_path(manager, TEST_DIR);
+ gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
gplugin_manager_refresh(manager);
plugin =
@@ -231,7 +231,7 @@
G_CALLBACK(test_gplugin_manager_signals_normal_unloaded),
&data);
- gplugin_manager_append_path(manager, TEST_DIR);
+ gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
gplugin_manager_refresh(manager);
plugin =
@@ -286,7 +286,7 @@
G_CALLBACK(test_gplugin_manager_signals_normal_unloaded),
&data);
- gplugin_manager_append_path(manager, TEST_DIR);
+ gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
gplugin_manager_refresh(manager);
plugin =
@@ -332,7 +332,7 @@
G_CALLBACK(test_gplugin_manager_signals_load_failed),
&data);
- gplugin_manager_append_path(manager, TEST_DIR);
+ gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
gplugin_manager_refresh(manager);
plugin = gplugin_manager_find_plugin(manager, "gplugin/native-load-failed");
@@ -382,7 +382,7 @@
G_CALLBACK(test_gplugin_manager_signals_unload_failed),
&data);
- gplugin_manager_append_path(manager, TEST_DIR);
+ gplugin_manager_append_path(manager, TEST_PLUGINS_DIR);
gplugin_manager_refresh(manager);
plugin =
--- a/gplugin/tests/test-unresolved-symbol.c Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/test-unresolved-symbol.c Mon Oct 16 22:35:31 2023 -0500
@@ -37,7 +37,7 @@
"*some_unresolved_symbol*");
gplugin_manager_remove_paths(manager);
- gplugin_manager_append_path(manager, PLUGIN_DIR);
+ gplugin_manager_append_path(manager, TEST_UNRESOLVED_SYMBOL_DIR);
gplugin_manager_refresh(manager);
g_test_assert_expected_messages();
--- a/gplugin/tests/test-versioned-dependencies.c Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/test-versioned-dependencies.c Mon Oct 16 22:35:31 2023 -0500
@@ -52,7 +52,7 @@
manager = gplugin_manager_get_default();
- gplugin_manager_append_path(manager, TEST_VERSIONED_DEPENDENCY_DIR);
+ gplugin_manager_append_path(manager, TEST_VERSIONED_DEPENDENCIES_DIR);
gplugin_manager_refresh(manager);
plugin = gplugin_manager_find_plugin(manager, "gplugin/super-dependent");
--- a/gplugin/tests/unresolved-symbol/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/unresolved-symbol/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -6,9 +6,12 @@
link_args = []
endif
-shared_module('unresolved-symbol', 'unresolved-symbol.c',
+plugin = shared_module('unresolved-symbol',
+ 'unresolved-symbol.c',
name_prefix : '',
link_args : link_args,
dependencies : [gplugin_dep, GLIB])
+all_native_test_plugins += {'unresolved-symbol': plugin}
+
endif
--- a/gplugin/tests/versioned-dependencies/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/gplugin/tests/versioned-dependencies/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -11,8 +11,12 @@
'baz',
'fez',
]
+plugins = []
foreach lib : LIBRARIES
- shared_library(lib, f'@lib@.c',
- name_prefix: '', dependencies : [gplugin_dep, GLIB])
+ plugins += shared_library(lib, f'@lib@.c',
+ name_prefix: '',
+ dependencies : [gplugin_dep, GLIB])
endforeach
+
+all_native_test_plugins += {'versioned-dependencies': plugins}
--- a/lua/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/lua/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -56,7 +56,7 @@
endif
# now add the library
-shared_library('gplugin-lua',
+gplugin_lua = shared_library('gplugin-lua',
GPLUGIN_LUA_SOURCES,
GPLUGIN_LUA_HEADERS,
name_prefix : '',
--- a/lua/tests/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/lua/tests/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -6,7 +6,8 @@
],
link_with : gplugin_loader_tests,
dependencies : [GLIB, GOBJECT, LUA, gplugin_dep])
-test('Lua Loader', e)
+test('Lua loader', e,
+ depends: gplugin_lua)
# Add the test plugins path to our environment variable
devenv.append('GPLUGIN_PLUGIN_PATH', meson.current_source_dir() / 'plugins')
--- a/python3/tests/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/python3/tests/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -6,7 +6,8 @@
],
link_with : gplugin_loader_tests,
dependencies : [GLIB, GOBJECT, PYTHON3, PYGOBJECT, gplugin_dep])
-test('Python3 loader', e)
+test('Python3 loader', e,
+ depends: gplugin_python3)
# we can't see the symbols in gplugin-python3 externally, so use the static
# version for testing
--- a/vala/tests/genie-plugins/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/vala/tests/genie-plugins/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -6,10 +6,13 @@
'unload-shutdown',
'unload-failed',
]
+all_genie_test_plugins = []
foreach lib : LIBRARIES
- shared_library(f'genie-@lib@-plugin', f'@lib@.gs',
- name_prefix: '', dependencies : [gplugin_dep, gplugin_vapi])
+ plugin = shared_library(f'genie-@lib@-plugin', f'@lib@.gs',
+ name_prefix: '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ all_genie_test_plugins += plugin
endforeach
# Add the test plugins path to our environment variable
--- a/vala/tests/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/vala/tests/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -1,3 +1,6 @@
+subdir('genie-plugins')
+subdir('plugins')
+
e = executable('test-vala-loading', 'test-vala-loading.c',
include_directories : include_directories('.'),
c_args : [
@@ -5,7 +8,8 @@
],
link_with : gplugin_loader_tests,
dependencies : [GLIB, GOBJECT, gplugin_dep])
-test('Vala loading', e)
+test('Vala loading', e,
+ depends: all_vala_test_plugins)
e = executable('test-genie-loading', 'test-genie-loading.c',
include_directories : include_directories('.'),
@@ -14,7 +18,5 @@
],
link_with : gplugin_loader_tests,
dependencies : [GLIB, GOBJECT, gplugin_dep])
-test('Genie loading', e)
-
-subdir('genie-plugins')
-subdir('plugins')
+test('Genie loading', e,
+ depends: all_genie_test_plugins)
--- a/vala/tests/plugins/meson.build Mon Oct 09 22:28:34 2023 -0500
+++ b/vala/tests/plugins/meson.build Mon Oct 16 22:35:31 2023 -0500
@@ -6,10 +6,13 @@
'unload-failed',
'unload-shutdown',
]
+all_vala_test_plugins = []
foreach lib : LIBRARIES
- shared_library(f'vala-@lib@-plugin', f'@lib@.vala',
- name_prefix: '', dependencies: [gplugin_dep, gplugin_vapi])
+ plugin = shared_library(f'vala-@lib@-plugin', f'@lib@.vala',
+ name_prefix: '',
+ dependencies: [gplugin_dep, gplugin_vapi])
+ all_vala_test_plugins += plugin
endforeach
# Add the test plugins path to our environment variable