@matheusbsbs / matheus-bagliano / commits / 16034fbe59
Fork 0

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>

Jeff King committed Aug 31, 2010 at 11:56 UTC 16034fbe59e88ec9592f73523cde97714d7c727c
1 file changed +9 -1
t/test-lib.sh
+9 -1
@@ -591,7 +591,15 @@ test_path_is_missing () {
591
592 test_must_fail () {
593 "$@"
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
603 }
604
605 # Similar to test_must_fail, but tolerates success, too. This is