Skip to content

Commit

Permalink
tests: make test_must_fail more verbose
Browse files Browse the repository at this point in the history
Because test_must_fail fails when a command succeeds, the
command frequently does not produce any output (since, after
all, it thought it was succeeding). So let's have
test_must_fail itself report that a problem occurred.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Aug 31, 2010
1 parent d8a9480 commit 16034fb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,15 @@ test_path_is_missing () {

test_must_fail () {
"$@"
test $? -gt 0 -a $? -le 129 -o $? -gt 192
exit_code=$?
if test $exit_code = 0; then
echo >&2 "test_must_fail: command succeeded: $*"
return 1
elif test $exit_code -gt 129 -a $exit_code -le 192; then
echo >&2 "test_must_fail: died by signal: $*"
return 1
fi
return 0
}

# Similar to test_must_fail, but tolerates success, too. This is
Expand Down

0 comments on commit 16034fb

Please sign in to comment.