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>
This commit is contained in:
Patrick Steinhardt
2025-06-02 08:44:49 +02:00
committed by Junio C Hamano
parent 5e0752b071
commit b44e63f405
4 changed files with 9 additions and 5 deletions

View File

@@ -17,6 +17,6 @@ if get_option('tests')
workdir: meson.current_source_dir(), workdir: meson.current_source_dir(),
env: credential_netrc_testenv, env: credential_netrc_testenv,
depends: test_dependencies + bin_wrappers + [credential_netrc], depends: test_dependencies + bin_wrappers + [credential_netrc],
timeout: 0, kwargs: test_kwargs,
) )
endif endif

View File

@@ -21,7 +21,7 @@ if get_option('tests')
env: subtree_test_environment, env: subtree_test_environment,
workdir: meson.current_source_dir() / 't', workdir: meson.current_source_dir() / 't',
depends: test_dependencies + bin_wrappers + [ git_subtree ], depends: test_dependencies + bin_wrappers + [ git_subtree ],
timeout: 0, kwargs: test_kwargs,
) )
endif endif

View File

@@ -2036,6 +2036,10 @@ subdir('templates')
# can properly set up test dependencies. The bin-wrappers themselves are set up # can properly set up test dependencies. The bin-wrappers themselves are set up
# at configuration time, so these are fine. # at configuration time, so these are fine.
if get_option('tests') if get_option('tests')
test_kwargs = {
'timeout': 0,
}
subdir('t') subdir('t')
endif endif

View File

@@ -51,7 +51,7 @@ clar_unit_tests = executable('unit-tests',
sources: clar_sources + clar_test_suites, sources: clar_sources + clar_test_suites,
dependencies: [libgit_commonmain], dependencies: [libgit_commonmain],
) )
test('unit-tests', clar_unit_tests) test('unit-tests', clar_unit_tests, kwargs: test_kwargs)
unit_test_programs = [ unit_test_programs = [
'unit-tests/t-reftable-basics.c', 'unit-tests/t-reftable-basics.c',
@@ -76,7 +76,7 @@ foreach unit_test_program : unit_test_programs
) )
test(unit_test_name, unit_test, test(unit_test_name, unit_test,
workdir: meson.current_source_dir(), workdir: meson.current_source_dir(),
timeout: 0, kwargs: test_kwargs,
) )
endforeach endforeach
@@ -1212,7 +1212,7 @@ foreach integration_test : integration_tests
workdir: meson.current_source_dir(), workdir: meson.current_source_dir(),
env: test_environment, env: test_environment,
depends: test_dependencies + bin_wrappers, depends: test_dependencies + bin_wrappers,
timeout: 0, kwargs: test_kwargs,
) )
endforeach endforeach