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
maint
Junio C Hamano 2021-10-25 16:07:00 -07:00
commit 67f310e1ad
1 changed files with 13 additions and 1 deletions

View File

@ -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