The process spawned in the hook uses the test's trash directory as CWD.
As long as it is alive, the directory cannot be removed on Windows.
Although the test succeeds, the 'test_done' that follows produces an
error message and leaves the trash directory around. Kill the process
before the test case advances.

Helped-by: Johannes Schindelin <>
Signed-off-by: Johannes Sixt <>
Am 06.09.2016 um 09:25 schrieb Johannes Schindelin:
> Maybe we should write a pid file in the sleep command instead, and kill it
> in the end? Something like this, maybe?

Yes, that is much better, thank you!

I did not extend the sleep time because it requires to change the file name
in the same patch.

I did experiment with 'while sleep 1; do :; done &' to spin indefinitely,
but the loop did not terminate in time in my tests on Windows for some
unknown reason (most likely because the killed process does not exit with
a non-zero code -- remember, Windows is not POSIX, particularly, when it
comes to signal handling).

t/ | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/t/ b/t/
index dd8f88d..7a6e33e 100755
--- a/t/
+++ b/t/
@@ -185,7 +185,9 @@ test_expect_success 'custom merge does not lock index' '
        git reset --hard anchor &&
        write_script <<-\EOF &&
                sleep 1 &
+               echo $! >
+       test_when_finished "kill \$(cat" &&
        test_write_lines >.gitattributes \
                "* merge=ours" "text merge=sleep-one-second" &&

Reply via email to