tests: Let each test change the highlight styles.
This way, each test can set custom styles to specific highlight contexts (to differentiate those contexts) without affecting later tests.
This commit is contained in:
parent
404d498e1d
commit
4068413dfe
@ -49,7 +49,9 @@
|
|||||||
|
|
||||||
local -a errors highlight_zone
|
local -a errors highlight_zone
|
||||||
local -A observed_result
|
local -A observed_result
|
||||||
|
local -A save_ZSH_HIGHLIGHT_STYLES
|
||||||
integer something_failed=0
|
integer something_failed=0
|
||||||
|
local unused_highlight='bg=red,underline' # a style unused by anything else, for tests to use
|
||||||
|
|
||||||
# Load the main script.
|
# Load the main script.
|
||||||
. ${0:h:h}/zsh-syntax-highlighting.zsh
|
. ${0:h:h}/zsh-syntax-highlighting.zsh
|
||||||
@ -57,12 +59,16 @@ integer something_failed=0
|
|||||||
# Activate the highlighter.
|
# Activate the highlighter.
|
||||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=($1)
|
ZSH_HIGHLIGHT_HIGHLIGHTERS=($1)
|
||||||
|
|
||||||
|
# Cache a pristine set of styles.
|
||||||
|
save_ZSH_HIGHLIGHT_STYLES=( "${(@kv)ZSH_HIGHLIGHT_STYLES}" )
|
||||||
|
|
||||||
# Process each test data file in test data directory.
|
# Process each test data file in test data directory.
|
||||||
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
|
||||||
|
|
||||||
# Load the data and prepare checking it.
|
# Load the data and prepare checking it.
|
||||||
PREBUFFER= BUFFER= ; expected_region_highlight=(); errors=()
|
PREBUFFER= BUFFER= ; expected_region_highlight=(); errors=()
|
||||||
echo -n "* ${data_file:t:r}: "
|
echo -n "* ${data_file:t:r}: "
|
||||||
|
ZSH_HIGHLIGHT_STYLES=( "${(@kv)save_ZSH_HIGHLIGHT_STYLES}" )
|
||||||
. $data_file
|
. $data_file
|
||||||
|
|
||||||
# Check the data declares $PREBUFFER or $BUFFER.
|
# Check the data declares $PREBUFFER or $BUFFER.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user