tests: Set ZSH_HIGHLIGHT_STYLES=() during tests
Since the _zsh_highlight_add_highlight that the tests use ignores ZSH_HIGHLIGHT_STYLES, we can test both an injective mapping and an empty mapping at once.
This commit is contained in:
parent
d3678ec7a8
commit
eaa4335c34
21
HACKING.md
21
HACKING.md
@ -6,7 +6,7 @@ core driver (`zsh-syntax-highlighting.zsh`), on the highlighters in the
|
|||||||
distribution, and on the test suite. It does not target third-party
|
distribution, and on the test suite. It does not target third-party
|
||||||
highlighter authors (although they may find it an interesting read).
|
highlighter authors (although they may find it an interesting read).
|
||||||
|
|
||||||
The 'main' highlighter
|
The `main` highlighter
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
The following function `pz` is useful when working on the `main` highlighting:
|
The following function `pz` is useful when working on the `main` highlighting:
|
||||||
@ -25,6 +25,25 @@ The following function `pz` is useful when working on the `main` highlighting:
|
|||||||
It prints, for each argument, its token breakdown, similar to how the main
|
It prints, for each argument, its token breakdown, similar to how the main
|
||||||
loop of the `main` highlighter sees it.
|
loop of the `main` highlighter sees it.
|
||||||
|
|
||||||
|
Testing the `brackets` highlighter
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Since the test harness empties `ZSH_HIGHLIGHT_STYLES` and the `brackets`
|
||||||
|
highlighter interrogates `ZSH_HIGHLIGHT_STYLES` to determine how to highlight,
|
||||||
|
tests must set the `bracket-level-#` keys themselves. For example:
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
|
||||||
|
BUFFER='echo ({x})'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
"6 6 bracket-level-1" # (
|
||||||
|
"7 7 bracket-level-2" # {
|
||||||
|
"9 9 bracket-level-2" # }
|
||||||
|
"10 10 bracket-level-1" # )
|
||||||
|
)
|
||||||
|
|
||||||
IRC channel
|
IRC channel
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
|
||||||
BUFFER='echo ({x}]'
|
BUFFER='echo ({x}]'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-3]=
|
||||||
|
|
||||||
BUFFER='echo $(echo ${(z)array})'
|
BUFFER='echo $(echo ${(z)array})'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
|
||||||
BUFFER='echo ({x})'
|
BUFFER='echo ({x})'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
|
@ -27,6 +27,9 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||||
|
|
||||||
BUFFER='echo ({x}'
|
BUFFER='echo ({x}'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||||
|
|
||||||
BUFFER='echo {x})'
|
BUFFER='echo {x})'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
|
@ -153,6 +153,7 @@ fi
|
|||||||
|
|
||||||
# Process each test data file in test data directory.
|
# Process each test data file in test data directory.
|
||||||
integer something_failed=0
|
integer something_failed=0
|
||||||
|
ZSH_HIGHLIGHT_STYLES=()
|
||||||
for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do
|
for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do
|
||||||
run_test "$data_file" | tee >($results_filter | ${0:A:h}/tap-colorizer.zsh) | grep -v '^not ok.*# TODO' | grep -Eq '^not ok|^ok.*# TODO' && (( something_failed=1 ))
|
run_test "$data_file" | tee >($results_filter | ${0:A:h}/tap-colorizer.zsh) | grep -v '^not ok.*# TODO' | grep -Eq '^not ok|^ok.*# TODO' && (( something_failed=1 ))
|
||||||
(( $pipestatus[1] )) && exit 2
|
(( $pipestatus[1] )) && exit 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user