Skip to content

Commit 45067fc

Browse files
peffgitster
authored andcommitted
t7300: repair filesystem permissions with test_when_finished
We create a directory that cannot be removed, confirm that it cannot be removed, and then fix it like: chmod 0 foo && test_must_fail git clean -d -f && chmod 755 foo If the middle step fails but leaves the directory (e.g., the bug is that clean does not notice the failure), this pollutes the test repo with an unremovable directory. Not only does this cause further tests to fail, but it means that "rm -rf" fails on the whole trash directory, and the user has to intervene manually to even re-run the test script. We can bump the "chmod 755" recovery to a test_when_finished block to be sure that it always runs. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7827352 commit 45067fc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

t/t7300-clean.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,10 @@ test_expect_success SANITY 'removal failure' '
426426
427427
mkdir foo &&
428428
touch foo/bar &&
429+
test_when_finished "chmod 755 foo" &&
429430
(exec <foo/bar &&
430431
chmod 0 foo &&
431-
test_must_fail git clean -f -d &&
432-
chmod 755 foo)
432+
test_must_fail git clean -f -d)
433433
'
434434

435435
test_expect_success 'nested git work tree' '

0 commit comments

Comments
 (0)