Skip to content

Commit 4dd4797

Browse files
committed
test harness: Print the expected-v.-actual on every failure, not just upon cardinality failures.
I was looking into something and wanted to see how a the second word in the array was highlighted, even though the failure was on the third word.
1 parent 5171ec5 commit 4dd4797

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/test-highlighting.zsh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ run_test_internal() {
154154
}; [[ -z $RETURN ]] || return $RETURN
155155
unset ARG
156156

157+
integer print_expected_and_actual=0
158+
157159
if (( unsorted )); then
158160
region_highlight=("${(@n)region_highlight}")
159161
expected_region_highlight=("${(@n)expected_region_highlight}")
@@ -177,6 +179,7 @@ run_test_internal() {
177179
if ! (( $+region_highlight[i] )); then
178180
print -r -- "not ok $i - unmatched expectation ($exp_start $exp_end $expected_highlight_zone[3])" \
179181
"${skip_mismatch:+"# TODO ${(qqq)skip_mismatch}"}"
182+
if [[ -z $skip_mismatch ]]; then (( ++print_expected_and_actual )); fi
180183
continue
181184
fi
182185
local -a highlight_zone; highlight_zone=( ${(z)region_highlight[i]} )
@@ -189,6 +192,7 @@ run_test_internal() {
189192
[[ $highlight_zone[3] != $expected_highlight_zone[3] ]]
190193
then
191194
print -r -- "not ok $i - $desc - expected ($exp_start $exp_end ${(qqq)expected_highlight_zone[3]}), observed ($start $end ${(qqq)highlight_zone[3]}). $todo"
195+
if [[ -z $todo ]]; then (( ++print_expected_and_actual )); fi
192196
else
193197
print -r -- "ok $i - $desc${todo:+ - }$todo"
194198
fi
@@ -221,7 +225,10 @@ run_test_internal() {
221225
details+="«$(typeset_p expected_region_highlight)» «$(typeset_p region_highlight)»"
222226
tap_escape $details; details=$REPLY
223227
print -r -- "not ok $i - cardinality check - $details${todo:+ - }$todo"
224-
228+
if [[ -z $todo ]]; then (( ++print_expected_and_actual )); fi
229+
fi
230+
fi
231+
if (( print_expected_and_actual )); then
225232
() {
226233
local -a left_column right_column
227234
left_column=( "expected_region_highlight" "${(qq)expected_region_highlight[@]}" )
@@ -234,7 +241,6 @@ run_test_internal() {
234241
| if type column >/dev/null; then column -t -s $'\t'; else cat; fi \
235242
| sed 's/^/# /'
236243
}
237-
fi
238244
fi
239245
}
240246

0 commit comments

Comments
 (0)