Skip to content

Commit b73d9a2

Browse files
aspiersgitster
authored andcommitted
tests: paint unexpectedly fixed known breakages in bold red
Change color of unexpectedly fixed known breakages to bold red. An unexpectedly passing test indicates that the test code is somehow broken or out of sync with the code it is testing. Either way this is an error which is potentially as bad as a failing test, and as such is no longer portrayed as a pass in the output. Signed-off-by: Adam Spiers <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5ebf89e commit b73d9a2

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

t/t0000-basic.sh

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,31 @@ test_expect_success 'pretend we have fixed a known breakage' "
145145
test_done
146146
EOF
147147
check_sub_test_lib_test passing-todo <<-\\EOF
148-
> ok 1 - pretend we have fixed a known breakage # TODO known breakage
149-
> # fixed 1 known breakage(s)
150-
> # passed all 1 test(s)
148+
> ok 1 - pretend we have fixed a known breakage # TODO known breakage vanished
149+
> # 1 known breakage(s) vanished; please update test(s)
151150
> 1..1
152151
EOF
153152
"
154153

154+
test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' "
155+
run_sub_test_lib_test partially-passing-todos \
156+
'2 TODO tests, one passing' <<-\\EOF &&
157+
test_expect_failure 'pretend we have a known breakage' 'false'
158+
test_expect_success 'pretend we have a passing test' 'true'
159+
test_expect_failure 'pretend we have fixed another known breakage' 'true'
160+
test_done
161+
EOF
162+
check_sub_test_lib_test partially-passing-todos <<-\\EOF
163+
> not ok 1 - pretend we have a known breakage # TODO known breakage
164+
> ok 2 - pretend we have a passing test
165+
> ok 3 - pretend we have fixed another known breakage # TODO known breakage vanished
166+
> # 1 known breakage(s) vanished; please update test(s)
167+
> # still have 1 known breakage(s)
168+
> # passed all remaining 1 test(s)
169+
> 1..3
170+
EOF
171+
"
172+
155173
test_expect_success 'pretend we have a pass, fail, and known breakage' "
156174
test_must_fail run_sub_test_lib_test \
157175
mixed-results1 'mixed results #1' <<-\\EOF &&
@@ -199,10 +217,10 @@ test_expect_success 'pretend we have a mix of all possible results' "
199217
> # false
200218
> not ok 8 - pretend we have a known breakage # TODO known breakage
201219
> not ok 9 - pretend we have a known breakage # TODO known breakage
202-
> ok 10 - pretend we have fixed a known breakage # TODO known breakage
203-
> # fixed 1 known breakage(s)
220+
> ok 10 - pretend we have fixed a known breakage # TODO known breakage vanished
221+
> # 1 known breakage(s) vanished; please update test(s)
204222
> # still have 2 known breakage(s)
205-
> # failed 3 among remaining 8 test(s)
223+
> # failed 3 among remaining 7 test(s)
206224
> 1..10
207225
EOF
208226
"

t/test-lib.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ test_failure_ () {
278278

279279
test_known_broken_ok_ () {
280280
test_fixed=$(($test_fixed+1))
281-
say_color "" "ok $test_count - $@ # TODO known breakage"
281+
say_color error "ok $test_count - $@ # TODO known breakage vanished"
282282
}
283283

284284
test_known_broken_failure_ () {
@@ -373,13 +373,18 @@ test_done () {
373373

374374
if test "$test_fixed" != 0
375375
then
376-
say_color pass "# fixed $test_fixed known breakage(s)"
376+
say_color error "# $test_fixed known breakage(s) vanished; please update test(s)"
377377
fi
378378
if test "$test_broken" != 0
379379
then
380380
say_color warn "# still have $test_broken known breakage(s)"
381-
msg="remaining $(($test_count-$test_broken)) test(s)"
381+
fi
382+
if test "$test_broken" != 0 || test "$test_fixed" != 0
383+
then
384+
test_remaining=$(( $test_count - $test_broken - $test_fixed ))
385+
msg="remaining $test_remaining test(s)"
382386
else
387+
test_remaining=$test_count
383388
msg="$test_count test(s)"
384389
fi
385390
case "$test_failure" in
@@ -393,7 +398,7 @@ test_done () {
393398

394399
if test $test_external_has_tap -eq 0
395400
then
396-
if test $test_count -gt 0
401+
if test $test_remaining -gt 0
397402
then
398403
say_color pass "# passed all $msg"
399404
fi

0 commit comments

Comments
 (0)