Skip to content

Commit 3ad4921

Browse files
peffgitster
authored andcommitted
t0061: simplify .bat test
The test added by 71f4960 (t0061: fix test for argv[0] with spaces (MINGW only), 2019-10-01) checks that we can use a .bat file with spaces as GIT_SSH. This is a good test in the sense that it's how the original bug was detected. And as the commit message there describes, there are some elements of the bug that are likely to come up with GIT_SSH and not elsewhere: namely that in addition to the .bat file having spaces, we must pass an argument with spaces (which happens naturally with ssh, since we pass the upload-pack shell command for the other side to run). But using GIT_SSH does complicate matters: 1. We actually run the ssh command _twice_, once to probe the ssh variant with "-G" in fill_ssh_args(), and then a second time to actually make the connection. So we have to account for that when checking the output. 2. Our fake ssh .bat file does not actually run ssh. So we expect the command to fail, but not before the .bat file has touched the "out" marker file that tells us it has run. This works now, but is fragile. In particular, the .bat file by default will echo commands it runs to stdout. From the perspective of the parent Git process, this is protocol-breaking garbage, and upon seeing it will die(). That is OK for now because we don't bother to do any cleanup of the child process. But there is a patch under discussion, dd3693e (transport-helper, connect: use clean_on_exit to reap children on abnormal exit, 2026-03-12), which causes us to kill() the .bat process. This happens before it actually touches the "out" file, causing the test to fail. We can simplify this by just using the "test-tool run-command" helper. That lets us run whatever command we like with the arguments we want. The argument here has a space, which is enough to trigger the original bug that 71f4960 was testing. I verified that by reverting eb7c786 (mingw: support spawning programs containing spaces in their names, 2019-07-16), the original fix, and confirming that the test fails (but succeeds without the revert). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 67ad421 commit 3ad4921

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

t/t0061-run-command.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,8 @@ test_expect_success MINGW 'can spawn .bat with argv[0] containing spaces' '
256256
rm -f out &&
257257
echo "echo %* >>out" >"$bat" &&
258258
259-
# Ask git to invoke .bat; clone will fail due to fake SSH helper
260-
test_must_fail env GIT_SSH="$bat" git clone myhost:src ssh-clone &&
261-
262-
# Spawning .bat can fail if there are two quoted cmd.exe arguments.
263-
# .bat itself is first (due to spaces in name), so just one more is
264-
# needed to verify. GIT_SSH will invoke .bat multiple times:
265-
# 1) -G myhost
266-
# 2) myhost "git-upload-pack src"
267-
# First invocation will always succeed. Test the second one.
268-
grep "git-upload-pack" out
259+
test-tool run-command run-command "$bat" "arg with spaces" &&
260+
test_grep "arg with spaces" out
269261
'
270262

271263
test_done

0 commit comments

Comments
 (0)