tests: Skip cardinality tests whenever any test point is expected to fail.
When writing an expected-to-fail test case, the cardinality of $region_highlight at the time the test is written may differ from the cardinality it will have once the bug is fixed. For example, with issue #641.5, the current highlighting is ['nice', 'x=y', 'y', 'ls'] — four elements — but the correct highlighting would have three elements: ['nice', 'x=y', 'ls']. There is no point in reporting a separate test failure for the cardinality check in this case, nor for 'ls' being highlighted as 'command' rather than 'default'. At the same time, in other cases the current and correct highlighting may have the same number of elements (for example, this would be the case for a hypothetical "the command word is highlighted as an alias rather than a function" bug). Thus, the previous commit, q.v..
This commit is contained in:
parent
d5a4a6e195
commit
4952325051
|
@ -24,6 +24,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 skip the cardinality check.
|
||||
`$expected_mismatch` is set implicitly if the `$todo` component is present.
|
||||
|
||||
**Note**: `$region_highlight` uses the same `"$i $j $style"` syntax but
|
||||
interprets the indexes differently.
|
||||
|
|
|
@ -145,7 +145,10 @@ run_test_internal() {
|
|||
local -a expected_highlight_zone; expected_highlight_zone=( ${(z)expected_region_highlight[i]} )
|
||||
integer exp_start=$expected_highlight_zone[1] exp_end=$expected_highlight_zone[2]
|
||||
local todo=
|
||||
(( $+expected_highlight_zone[4] )) && todo="# TODO $expected_highlight_zone[4]"
|
||||
if (( $+expected_highlight_zone[4] )); then
|
||||
todo="# TODO $expected_highlight_zone[4]"
|
||||
: ${expected_mismatch:="cardinality check disabled whilst regular test points are expected to fail"}
|
||||
fi
|
||||
if ! (( $+region_highlight[i] )); then
|
||||
print -r -- "not ok $i - unmatched expectation ($exp_start $exp_end $expected_highlight_zone[3])"
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue
Block a user