Skip to content

Commit bbfbcd2

Browse files
avargitster
authored andcommitted
test-lib: have --immediate emit valid TAP on failure
Change the "--immediate" option so that it emits valid TAP on failure. Before this it would omit the required plan at the end, e.g. under SANITIZE=leak we'd show a "No plan found in TAP output" error from "prove": $ prove t0006-date.sh :: --immediate t0006-date.sh .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/22 subtests Test Summary Report ------------------- t0006-date.sh (Wstat: 256 Tests: 22 Failed: 1) Failed test: 22 Non-zero exit status: 1 Parse errors: No plan found in TAP output Files=1, Tests=22, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.18 cusr 0.06 csys = 0.27 CPU) Result: FAIL Now we'll emit output that doesn't result in TAP parsing failures: $ prove t0006-date.sh :: --immediate t0006-date.sh .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/22 subtests Test Summary Report ------------------- t0006-date.sh (Wstat: 256 Tests: 22 Failed: 1) Failed test: 22 Non-zero exit status: 1 Files=1, Tests=22, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.19 cusr 0.05 csys = 0.26 CPU) Result: FAIL Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a68dfad commit bbfbcd2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

t/t0000-basic.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ test_expect_success 'subtest: 2/3 tests passing' '
101101
EOF
102102
'
103103

104+
test_expect_success 'subtest: --immediate' '
105+
run_sub_test_lib_test_err partial-pass \
106+
--immediate &&
107+
check_sub_test_lib_test_err partial-pass \
108+
<<-\EOF_OUT 3<<-EOF_ERR
109+
> ok 1 - passing test #1
110+
> not ok 2 - failing test #2
111+
> # false
112+
> 1..2
113+
EOF_OUT
114+
EOF_ERR
115+
'
116+
104117
test_expect_success 'subtest: a failing TODO test' '
105118
write_and_run_sub_test_lib_test failing-todo <<-\EOF &&
106119
test_expect_success "passing test" "true"

t/test-lib.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,11 @@ test_failure_ () {
806806
say_color error "not ok $test_count - $1"
807807
shift
808808
printf '%s\n' "$*" | sed -e 's/^/# /'
809-
test "$immediate" = "" || _error_exit
809+
if test -n "$immediate"
810+
then
811+
say_color error "1..$test_count"
812+
_error_exit
813+
fi
810814
}
811815

812816
test_known_broken_ok_ () {

0 commit comments

Comments
 (0)