From: Junio C Hamano Date: Mon, 25 Oct 2021 23:07:00 +0000 (-0700) Subject: Merge branch 'ab/test-cleanly-recreate-trash-directory' X-Git-Tag: v2.34.0-rc0~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=67f310e1adfe3cc186aa3dd5c1acfc94398540cc;p=thirdparty%2Fgit.git 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 --- 67f310e1adfe3cc186aa3dd5c1acfc94398540cc diff --cc t/test-lib.sh index 151da80c56,d820910154..a291a5d4a2 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@@ -1381,34 -1379,25 +1381,46 @@@ the test_done fi +# skip non-whitelisted tests when compiled with SANITIZE=leak +if test -n "$SANITIZE_LEAK" +then + if test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false + then + # We need to see it in "git env--helper" (via + # test_bool_env) + export TEST_PASSES_SANITIZE_LEAK + + if ! test_bool_env TEST_PASSES_SANITIZE_LEAK false + then + skip_all="skipping $this_test under GIT_TEST_PASSING_SANITIZE_LEAK=true" + test_done + fi + fi +elif test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false +then + error "GIT_TEST_PASSING_SANITIZE_LEAK=true has no effect except when compiled with SANITIZE=leak" +fi + # Last-minute variable setup +USER_HOME="$HOME" HOME="$TRASH_DIRECTORY" GNUPGHOME="$HOME/gnupg-home-not-used" -export HOME GNUPGHOME +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