Skip to content

Commit 231e86c

Browse files
phillipwoodgitster
authored andcommitted
t4053: avoid race when killing background processes
The test 'diff --no-index reads from pipes' starts a couple of background processes that write to the pipes that are passed to "diff --no-index". If the test passes then we expect these processes to exit as all their output will have been read. However if the test fails then we want to make sure they do not hang about on the users machine and the test remembers they should be killed by calling test_when_finished "! kill $!" after each background process is created. Unfortunately there is a race where test_when_finished may run before the background process exits even when all its output has been read resulting in the kill command succeeding which causes the test to fail. Fix this by ignoring the exit status of the kill command. If the diff is successful we could instead wait for the background process to exit and check their status but that feels like it is testing the platform's printf implementation rather than git's code. Reported-by: Jeff King <[email protected]> Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1e3f265 commit 231e86c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

t/t4053-diff-no-index.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ test_expect_success PIPE,SYMLINKS 'diff --no-index reads from pipes' '
248248
{
249249
(test_write_lines a b c >old) &
250250
} &&
251-
test_when_finished "! kill $!" &&
251+
test_when_finished "kill $! || :" &&
252252
{
253253
(test_write_lines a x c >new) &
254254
} &&
255-
test_when_finished "! kill $!" &&
255+
test_when_finished "kill $! || :" &&
256256
257257
cat >expect <<-EOF &&
258258
diff --git a/old b/new-link

0 commit comments

Comments
 (0)