Skip to content

Commit bdd04b9

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c0d3f90 commit bdd04b9

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

contrib/credential/netrc/meson.build

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ credential_netrc = custom_target(
77
install_dir: get_option('libexecdir') / 'git-core',
88
)
99

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())
1213

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ git_subtree = custom_target(
1212
install_dir: get_option('libexecdir') / 'git-core',
1313
)
1414

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())
1718

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
2527

2628
if get_option('docs').contains('man')
2729
subtree_xml = custom_target(

0 commit comments

Comments
 (0)