meson: respect 'tests' build option in contrib
Both the "netrc" credential helper and git-subtree(1) from "contrib/" carry a couple of tests with them. These tests get wired up in Meson unconditionally even in the case where `-Dtests=false`. As those tests depend on the `test_enviroment` variable, which only gets defined in case `-Dtests=true`, the result is an error: ``` $ meson setup -Dtests=false -Dcontrib=subtree build [...] contrib/subtree/meson.build:15:27: ERROR: Unknown variable "test_environment". ``` Fix the issue by not defining these tests at all in case the "tests" option is set to `false`. Reported-by: Sam James <sam@gentoo.org> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Mar 31, 2025 at 10:33 UTC
bdd04b91c3492142dde585a763ad923c3aefbc7b
2 files changed
+23
-19
contrib/credential/netrc/meson.build
+12
-10
@@ -7,14 +7,16 @@ credential_netrc = custom_target(
7
install_dir: get_option('libexecdir') / 'git-core',
8
)
9
10
-credential_netrc_testenv = test_environment
11
-credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())
10
+if get_option('tests')
11
+ credential_netrc_testenv = test_environment
12
+ credential_netrc_testenv.set('CREDENTIAL_NETRC_PATH', credential_netrc.full_path())
13
13
-test('t-git-credential-netrc',
14
- shell,
15
- args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],
16
- workdir: meson.current_source_dir(),
17
- env: credential_netrc_testenv,
18
- depends: test_dependencies + bin_wrappers + [credential_netrc],
19
- timeout: 0,
20
-)
14
+ test('t-git-credential-netrc',
15
+ shell,
16
+ args: [ meson.current_source_dir() / 't-git-credential-netrc.sh' ],
17
+ workdir: meson.current_source_dir(),
18
+ env: credential_netrc_testenv,
19
+ depends: test_dependencies + bin_wrappers + [credential_netrc],
20
+ timeout: 0,
21
+ )
22
+endif
contrib/subtree/meson.build
+11
-9
@@ -12,16 +12,18 @@ git_subtree = custom_target(
12
install_dir: get_option('libexecdir') / 'git-core',
13
)
14
15
-subtree_test_environment = test_environment
16
-subtree_test_environment.prepend('PATH', meson.current_build_dir())
15
+if get_option('tests')
16
+ subtree_test_environment = test_environment
17
+ subtree_test_environment.prepend('PATH', meson.current_build_dir())
18
18
-test('t7900-subtree', shell,
19
- args: [ 't7900-subtree.sh' ],
20
- env: subtree_test_environment,
21
- workdir: meson.current_source_dir() / 't',
22
- depends: test_dependencies + bin_wrappers + [ git_subtree ],
23
- timeout: 0,
24
-)
19
+ test('t7900-subtree', shell,
20
+ args: [ 't7900-subtree.sh' ],
21
+ env: subtree_test_environment,
22
+ workdir: meson.current_source_dir() / 't',
23
+ depends: test_dependencies + bin_wrappers + [ git_subtree ],
24
+ timeout: 0,
25
+ )
26
+endif
27
28
if get_option('docs').contains('man')
29
subtree_xml = custom_target(