aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Junio C Hamano <gitster@pobox.com> 2021-10-25 16:07:00 -0700
committerGravatar Junio C Hamano <gitster@pobox.com> 2021-10-25 16:07:00 -0700
commit67f310e1adfe3cc186aa3dd5c1acfc94398540cc (patch)
tree0603be4f09da62ff0118448b44994e6b98bd5ec4
parent97ab03b12a044ded55de68aac160ffb72c951830 (diff)
parent5d22e18965664fc4036843cd22424ce38c8fa866 (diff)
downloadgit-67f310e1adfe3cc186aa3dd5c1acfc94398540cc.tar.gz
git-67f310e1adfe3cc186aa3dd5c1acfc94398540cc.zip
Merge branch 'ab/test-cleanly-recreate-trash-directory'
Improve test framework around unwritable directories. * ab/test-cleanly-recreate-trash-directory: test-lib.sh: try to re-chmod & retry on failed trash removal
-rw-r--r--t/test-lib.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 151da80c56..a291a5d4a2 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1407,8 +1407,20 @@ HOME="$TRASH_DIRECTORY"
GNUPGHOME="$HOME/gnupg-home-not-used"
export HOME GNUPGHOME USER_HOME
+# "rm -rf" existing trash directory, even if a previous run left it
+# with bad permissions.
+remove_trash_directory () {
+ dir="$1"
+ if ! rm -rf "$dir" 2>/dev/null
+ then
+ chmod -R u+rwx "$dir"
+ rm -rf "$dir"
+ fi
+ ! test -d "$dir"
+}
+
# Test repository
-rm -fr "$TRASH_DIRECTORY" || {
+remove_trash_directory "$TRASH_DIRECTORY" || {
GIT_EXIT_OK=t
echo >&5 "FATAL: Cannot prepare test area"
exit 1