From: Junio C Hamano Date: Tue, 25 Apr 2017 06:39:47 +0000 (-0700) Subject: test-lib.sh: do not barf under --debug at the end of the test X-Git-Tag: v2.14.0-rc0~196^2~1 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4d0912a206a32e9763424363617e8425f049f344;p=git-core%2Fgit.git test-lib.sh: do not barf under --debug at the end of the test The original did "does $remove_trash exist? Then go one level above and remove it". There was no problem under "--debug", where the variable is left empty, as the first "test -d $remove_trash" would have said "No, it doesn't". With the check implemented in the previous step, we'd always get an error under "--debug". Noticed-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/t/test-lib.sh b/t/test-lib.sh index cb0766b9e..d2f9ad5ae 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -760,13 +760,16 @@ 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 -n "$remove_trash" + then + test -d "$remove_trash" || + 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 "$remove_trash")" && + rm -rf "$(basename "$remove_trash")" || + error "Tests passed but test cleanup failed; aborting" + fi test_at_end_hook_ exit 0 ;;