Git fork

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>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
bdd04b91 c0d3f90e

+23 -19
+12 -10
contrib/credential/netrc/meson.build
··· 7 7 install_dir: get_option('libexecdir') / 'git-core', 8 8 ) 9 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()) 12 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
+11 -9
contrib/subtree/meson.build
··· 12 12 install_dir: get_option('libexecdir') / 'git-core', 13 13 ) 14 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()) 17 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 25 27 26 28 if get_option('docs').contains('man') 27 29 subtree_xml = custom_target(