meson: introduce kwargs variable for tests
Meson has the ability to create a kwargs dictionary that can then be passed to any function call with the `kwargs:` positional argument. This allows one to deduplicate common parameters that one wishes to pass to several different function invocations. Our tests already have one common parameter that we use everywhere, "timeout", and we're about to add a second common parameter in the next commit. Let's prepare for this by introducing `test_kwargs` so that we can deduplicate these common arguments. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Jun 2, 2025 at 08:44 UTC
b44e63f405a6508652dab2d4ade71e6f0afb9f36
4 files changed
+9
-5
contrib/credential/netrc/meson.build
+1
-1
@@ -17,6 +17,6 @@ if get_option('tests')
17
workdir: meson.current_source_dir(),
18
env: credential_netrc_testenv,
19
depends: test_dependencies + bin_wrappers + [credential_netrc],
20
- timeout: 0,
20
+ kwargs: test_kwargs,
21
)
22
endif
contrib/subtree/meson.build
+1
-1
@@ -21,7 +21,7 @@ if get_option('tests')
21
env: subtree_test_environment,
22
workdir: meson.current_source_dir() / 't',
23
depends: test_dependencies + bin_wrappers + [ git_subtree ],
24
- timeout: 0,
24
+ kwargs: test_kwargs,
25
)
26
endif
27
meson.build
+4
@@ -2036,6 +2036,10 @@ subdir('templates')
2036
# can properly set up test dependencies. The bin-wrappers themselves are set up
2037
# at configuration time, so these are fine.
2038
if get_option('tests')
2039
+ test_kwargs = {
2040
+ 'timeout': 0,
2041
+ }
2042
+
2043
subdir('t')
2044
endif
2045
t/meson.build
+3
-3
@@ -51,7 +51,7 @@ clar_unit_tests = executable('unit-tests',
51
sources: clar_sources + clar_test_suites,
52
dependencies: [libgit_commonmain],
53
)
54
-test('unit-tests', clar_unit_tests)
54
+test('unit-tests', clar_unit_tests, kwargs: test_kwargs)
55
56
unit_test_programs = [
57
'unit-tests/t-reftable-basics.c',
@@ -76,7 +76,7 @@ foreach unit_test_program : unit_test_programs
76
)
77
test(unit_test_name, unit_test,
78
workdir: meson.current_source_dir(),
79
- timeout: 0,
79
+ kwargs: test_kwargs,
80
)
81
endforeach
82
@@ -1212,7 +1212,7 @@ foreach integration_test : integration_tests
1212
workdir: meson.current_source_dir(),
1213
env: test_environment,
1214
depends: test_dependencies + bin_wrappers,
1215
- timeout: 0,
1215
+ kwargs: test_kwargs,
1216
)
1217
endforeach
1218