tests: Make $expected_mismatch skip the cardinality check, rather

than consider it an expected failure.

With this change, if $expected_region_highlight and $region_highlight
coincidentally have the same number of elements, the test won't be considered
to fail.

This is useful in conjunction with the next commit, q.v..

At this time, no tests set $expected_mismatch explicitly.  However, the
commit after next (this commit's grandchild) will add a test that will
set $expected_mismatch implicitly, using the functionality in the next
commit (this commit's child).
This commit is contained in:
Daniel Shahaf 2019-11-10 11:29:20 +00:00
parent e209cbe61a
commit d5a4a6e195
2 changed files with 7 additions and 5 deletions

View File

@ -23,8 +23,7 @@ need not match the order in `$region_highlight`.
Normally, tests fail if `$expected_region_highlight` and `$region_highlight`
have different numbers of elements. Tests may set `$expected_mismatch` to an
explanation string (like `$todo`) to avoid this and mark the cardinality check
as todo.
explanation string (like `$todo`) to avoid this and skip the cardinality check.
**Note**: `$region_highlight` uses the same `"$i $j $style"` syntax but
interprets the indexes differently.

View File

@ -171,14 +171,17 @@ run_test_internal() {
unset desc
done
if (( $#expected_region_highlight == $#region_highlight )); then
print -r -- "ok $i - cardinality check" "${expected_mismatch:+"# TODO ${(qqq)expected_mismatch}"}"
if [[ -n $expected_mismatch ]]; then
tap_escape $expected_mismatch; expected_mismatch=$REPLY
print "ok $i - cardinality check" "# SKIP $expected_mismatch"
elif (( $#expected_region_highlight == $#region_highlight )); then
print -r -- "ok $i - cardinality check"
else
local details
details+="have $#expected_region_highlight expectations and $#region_highlight region_highlight entries: "
details+="«$(typeset_p expected_region_highlight)» «$(typeset_p region_highlight)»"
tap_escape $details; details=$REPLY
print -r -- "not ok $i - cardinality check" "$details" "${expected_mismatch:+"# TODO ${(qqq)expected_mismatch}"}"
print -r -- "not ok $i - cardinality check - $details"
fi
}