t3600: clean up permissions test properly
authorMichael Haggerty <mhagger@alum.mit.edu>
Mon, 22 May 2017 14:17:31 +0000 (16:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 May 2017 05:29:51 +0000 (14:29 +0900)
The test of failing `git rm -f` removes the write permissions on the
test directory, but fails to restore them if the test fails. This
means that the test temporary directory cannot be cleaned up, which
means that subsequent attempts to run the test fail mysteriously.

Instead, do the cleanup in a `test_when_finished` block so that it
can't be skipped.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3600-rm.sh
index 5f9913ba33d3edc848b03fc37bed587fe5c54849..f8568f8841d34d17f3d8fdae4d8d2404a6693c4d 100755 (executable)
@@ -97,9 +97,9 @@ test_expect_success FUNNYNAMES \
 embedded'"
 
 test_expect_success SANITY 'Test that "git rm -f" fails if its rm fails' '
+       test_when_finished "chmod 775 ." &&
        chmod a-w . &&
-       test_must_fail git rm -f baz &&
-       chmod 775 .
+       test_must_fail git rm -f baz
 '
 
 test_expect_success \