Skip to content

Commit

Permalink
t7300: repair filesystem permissions with test_when_finished
Browse files Browse the repository at this point in the history
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Jul 2, 2014
1 parent 7827352 commit 45067fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions t/t7300-clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ test_expect_success SANITY 'removal failure' '
mkdir foo &&
touch foo/bar &&
test_when_finished "chmod 755 foo" &&
(exec <foo/bar &&
chmod 0 foo &&
test_must_fail git clean -f -d &&
chmod 755 foo)
test_must_fail git clean -f -d)
'

test_expect_success 'nested git work tree' '
Expand Down

0 comments on commit 45067fc

Please sign in to comment.