From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH] t7300: repair filesystem permissions with test_when_finished
Date: Wed, 2 Jul 2014 14:44:30 -0400 [thread overview]
Message-ID: <20140702184429.GA32538@sigill.intra.peff.net> (raw)
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>
---
t/t7300-clean.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 74de814..04118ad 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -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' '
--
2.0.0.566.gfe3e6b2
next reply other threads:[~2014-07-02 18:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-02 18:44 Jeff King [this message]
2014-07-02 19:01 ` [PATCH] t7300: repair filesystem permissions with test_when_finished Jonathan Nieder
2014-07-02 19:03 ` Jeff King
2014-07-02 20:05 ` Junio C Hamano
2014-07-02 20:06 ` Junio C Hamano
2014-07-02 19:11 ` [RFH] "git clean" deletes excluded files in untracked directories Jeff King
2014-07-22 21:39 ` Junio C Hamano
2014-07-22 22:53 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140702184429.GA32538@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).