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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Apr 24, 2017 at 23:39 UTC 4d0912a206a32e9763424363617e8425f049f344
1 file changed +8 -5
t/test-lib.sh
+8 -5
@@ -760,13 +760,16 @@ test_done () {
760 say "1..$test_count$skip_all"
761 fi
762
763 - test -d "$remove_trash" ||
764 - error "Tests passed but trash directory already removed before test cleanup; aborting"
763 + if test -n "$remove_trash"
764 + then
765 + test -d "$remove_trash" ||
766 + error "Tests passed but trash directory already removed before test cleanup; aborting"
767
766 - cd "$(dirname "$remove_trash")" &&
767 - rm -rf "$(basename "$remove_trash")" ||
768 - error "Tests passed but test cleanup failed; aborting"
768 + cd "$(dirname "$remove_trash")" &&
769 + rm -rf "$(basename "$remove_trash")" ||
770 + error "Tests passed but test cleanup failed; aborting"
771
772 + fi
773 test_at_end_hook_
774
775 exit 0 ;;