t6026: clarify the point of "kill $(cat sleep.pid)"

We lengthened the time the leftover process sleeps in the previous commit to make sure it will be there while 'git merge' runs and finishes. It therefore needs to be killed before leaving the test. And it needs to be killed even when 'git merge' fails, so it has to be triggered via test_when_finished mechanism. Explain all that in a large comment, and move the use site of test_when_finished to immediately before 'git merge' invocation, where the process is spawned. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed Nov 11, 2016 at 21:24 UTC fdf4f6c79b4260e98729ebeb208036765595e9ac
1 file changed +9 -1
t/t6026-merge-attr.sh
+9 -1
@@ -187,12 +187,20 @@ test_expect_success 'custom merge does not lock index' '
187 sleep 3600 &
188 echo $! >sleep.pid
189 EOF
190 - test_when_finished "kill \$(cat sleep.pid)" &&
190
191 test_write_lines >.gitattributes \
192 "* merge=ours" "text merge=sleep-an-hour" &&
193 test_config merge.ours.driver true &&
194 test_config merge.sleep-an-hour.driver ./sleep-an-hour.sh &&
195 +
196 + # We are testing that the custom merge driver does not block
197 + # index.lock on Windows due to an inherited file handle.
198 + # To ensure that the backgrounded process ran sufficiently
199 + # long (and has been started in the first place), we do not
200 + # ignore the result of the kill command.
201 + # By packaging the command in test_when_finished, we get both
202 + # the correctness check and the clean-up.
203 + test_when_finished "kill \$(cat sleep.pid)" &&
204 git merge master
205 '
206