summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-10-25 16:07:00 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-10-25 16:07:00 -0700
commit67f310e1adfe3cc186aa3dd5c1acfc94398540cc (patch)
tree0603be4f09da62ff0118448b44994e6b98bd5ec4 /t
parentMerge branch 'jc/doc-commit-header-continuation-line' (diff)
parenttest-lib.sh: try to re-chmod & retry on failed trash removal (diff)
downloadtgif-67f310e1adfe3cc186aa3dd5c1acfc94398540cc.tar.xz
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
Diffstat (limited to 't')
-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