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..
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).
The test point is XPASSing, which makes CI red. As a duct tape measure to turn
CI green again, update the test expectations to make it XFAIL. The hacky part
is that the expectation set by this commit will never be met; the test point
will never XPASS now until its expectations are changed again.
Issue #623 remains open to track setting the test expectation to the correct
value (i.e., make the test XFAIL in a manner that _will_ XPASS if the bug is
fixed; in other words, pay off the technical debt created by this commit).
Issue #616 remains open to fix the actual bug.
The effect of the bug was that «-:» was considered an option taking an argument
(see the parsing of the associative array in lines 692-693).
As to preventing recurrence, add a warning comment. We _could_ change
the separator from colon to something else, but colon is idiomatic for
this use (see, e.g., passwd(5)), and the problem will be unlikely to
recur if and when we add a third field to the assoc's values. (For
example, jexec(1), chroot(1), and even ssh(1) would benefit from a third
field saying how many positional arguments to skip before the positional
argument that's to be the command word — though in the last two cases,
specifying an "inner" command is optional.)
As of this writing, it seems that the 'type' builtin poisons the commands hash
in a way that breaks AUTO_CD to absolute paths that don't end with a slash.