Skip to content

Commit 16034fb

Browse files
peffgitster
authored andcommitted
tests: make test_must_fail more verbose
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>
1 parent d8a9480 commit 16034fb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

t/test-lib.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,15 @@ test_path_is_missing () {
591591

592592
test_must_fail () {
593593
"$@"
594-
test $? -gt 0 -a $? -le 129 -o $? -gt 192
594+
exit_code=$?
595+
if test $exit_code = 0; then
596+
echo >&2 "test_must_fail: command succeeded: $*"
597+
return 1
598+
elif test $exit_code -gt 129 -a $exit_code -le 192; then
599+
echo >&2 "test_must_fail: died by signal: $*"
600+
return 1
601+
fi
602+
return 0
595603
}
596604

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

0 commit comments

Comments
 (0)