From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>,
"Stefan Beller" <sbeller@google.com>,
"Johannes Sixt" <j6t@kdbg.org>,
"David Turner" <dturner@twosigma.com>,
git@vger.kernel.org
Subject: Re: [PATCH] test-lib: abort when can't remove trash directory
Date: Mon, 24 Apr 2017 23:05:15 -0700 [thread overview]
Message-ID: <xmqqmvb5uin8.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170424075241.ybbq2cpvbmwtdwz7@sigill.intra.peff.net> (Jeff King's message of "Mon, 24 Apr 2017 03:52:42 -0400")
Jeff King <peff@peff.net> writes:
> Good point. There's only one caller, but it does care about being in
> that directory.
>
>> Second try that hopefully is much less damaging
I've been carrying it as a SQUASH??? patch, but I think it is better
to split it as a separate pach, as removal of $remove_trash is an
optional thing. The main thing, i.e. SZEDER's "abort when trash is
already gone or when we cannot remove" _can_ be (and is) correctly
done with his pach alone.
So here is what I queued on top.
-- >8 --
Subject: [PATCH] test-lib: retire $remove_trash variable
The convention "$remove_trash is set to the trash directory that is
used during the test, so that it will be removed at the end, but
under --debug option we set the varilable to empty string to
preserve the directory" made sense back when it was introduced, as
there was no $TRASH_DIRECTORY variable. These days, since no tests
looks at the variable, it is obscure and even risks that by mistake
the variable gets used for something else (e.g. remove_trash=yes)
and cause us misbehave.
Rewrite the clean-up sequence in test_done helper to explicitly
check the $debug condition and remove the trash directory using
the $TRASH_DIRECTORY variable.
Note that "go to the directory one level above the trash and then
remove it" is kept and this is deliverate; test_at_end_hook_ will
keep running from the expected location, and also some platforms may
not like a directory that is serving as the $cwd of a still-active
process removed.
We _might_ want to rewrite
cd "$(dirname "$TRASH_DIRECTORY")"
further to
cd "$TRASH_DIRECTORY/.."
to lose one extra process, but let's leave it to a later patch.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
t/test-lib.sh | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index cb0766b9ee..976566047d 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -760,12 +760,15 @@ test_done () {
say "1..$test_count$skip_all"
fi
- test -d "$remove_trash" ||
- error "Tests passed but trash directory already removed before test cleanup; aborting"
+ if test -z "$debug"
+ then
+ test -d "$TRASH_DIRECTORY" ||
+ error "Tests passed but trash directory already removed before test cleanup; aborting"
- cd "$(dirname "$remove_trash")" &&
- rm -rf "$(basename "$remove_trash")" ||
- error "Tests passed but test cleanup failed; aborting"
+ cd "$(dirname "$TRASH_DIRECTORY")" &&
+ rm -fr "$TRASH_DIRECTORY" ||
+ error "Tests passed but test cleanup failed; aborting"
+ fi
test_at_end_hook_
@@ -921,7 +924,6 @@ case "$TRASH_DIRECTORY" in
/*) ;; # absolute path is good
*) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;;
esac
-test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY
rm -fr "$TRASH_DIRECTORY" || {
GIT_EXIT_OK=t
echo >&5 "FATAL: Cannot prepare test area"
--
2.13.0-rc0-308-g931de5db53
next prev parent reply other threads:[~2017-04-25 6:05 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-10 12:59 [PATCH] t6500: don't run detached auto gc at the end of the test script SZEDER Gábor
2017-04-10 13:58 ` Jeff King
2017-04-10 16:31 ` SZEDER Gábor
2017-04-10 16:35 ` Jeff King
2017-04-10 16:56 ` SZEDER Gábor
2017-04-10 17:01 ` Jeff King
2017-04-11 21:32 ` Johannes Sixt
2017-04-12 0:27 ` SZEDER Gábor
2017-04-12 0:50 ` Jeff King
2017-04-12 22:03 ` SZEDER Gábor
2017-04-12 22:07 ` [PATCHv2] " SZEDER Gábor
2017-04-13 10:31 ` [PATCHv2.1] t6500: wait for " SZEDER Gábor
2017-04-13 16:06 ` David Turner
2017-04-13 16:44 ` Jeff King
2017-04-13 18:08 ` SZEDER Gábor
2017-04-13 18:12 ` Jeff King
2017-04-13 16:37 ` [PATCH] t6500: don't run " Jeff King
2017-04-13 17:55 ` Stefan Beller
2017-04-13 17:57 ` Jeff King
2017-04-13 19:03 ` SZEDER Gábor
2017-04-13 19:12 ` Jeff King
2017-04-13 19:35 ` SZEDER Gábor
2017-04-14 20:08 ` Jeff King
2017-04-20 16:42 ` SZEDER Gábor
2017-04-20 16:45 ` Jeff King
2017-04-20 16:52 ` [PATCH] test-lib: abort when can't remove trash directory SZEDER Gábor
2017-04-20 19:06 ` Jeff King
2017-04-21 0:48 ` Junio C Hamano
2017-04-21 20:06 ` SZEDER Gábor
2017-04-21 20:15 ` Jeff King
2017-04-24 0:14 ` Junio C Hamano
2017-04-24 1:43 ` Jeff King
2017-04-24 2:58 ` Junio C Hamano
2017-04-24 4:02 ` Junio C Hamano
2017-04-24 7:52 ` Jeff King
2017-04-24 9:39 ` Torsten Bögershausen
2017-04-24 9:46 ` Jeff King
2017-04-25 2:31 ` Junio C Hamano
2017-04-25 6:05 ` Junio C Hamano [this message]
2017-04-25 6:07 ` Jeff King
2017-04-25 6:31 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqmvb5uin8.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=dturner@twosigma.com \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=peff@peff.net \
--cc=sbeller@google.com \
--cc=szeder.dev@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).