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>
This commit is contained in:
Junio C Hamano 2017-04-24 23:39:47 -07:00
parent df4c0d1a79
commit 4d0912a206

View File

@ -760,13 +760,16 @@ test_done () {
say "1..$test_count$skip_all" say "1..$test_count$skip_all"
fi fi
test -d "$remove_trash" || if test -n "$remove_trash"
error "Tests passed but trash directory already removed before test cleanup; aborting" then
test -d "$remove_trash" ||
error "Tests passed but trash directory already removed before test cleanup; aborting"
cd "$(dirname "$remove_trash")" && cd "$(dirname "$remove_trash")" &&
rm -rf "$(basename "$remove_trash")" || rm -rf "$(basename "$remove_trash")" ||
error "Tests passed but test cleanup failed; aborting" error "Tests passed but test cleanup failed; aborting"
fi
test_at_end_hook_ test_at_end_hook_
exit 0 ;; exit 0 ;;