Skip to content

Commit e6eea1f

Browse files
committed
test harness: Don't leak options from test files to the test harness.
Fixes an issue whereby the '# TODO "issue #687"' directive in the output of opt-shwordsplit1.zsh was truncated, because the test itself had set the SH_WORD_SPLIT option and that affected the evaluation of «${(z)expected_region_highlight[i]}» in the test harness. Furthermore, this patch also independently fixes the error under zsh-5.0.8 and earlier that was fixed by the previous commit.
1 parent 9938932 commit e6eea1f

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

tests/test-highlighting.zsh

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,27 @@ run_test_internal() {
123123
local skip_mismatch
124124
local -a expected_region_highlight region_highlight
125125

126-
. "$srcdir"/"$1"
126+
local ARG="$1"
127+
() {
128+
setopt localoptions
129+
. "$srcdir"/"$ARG"
127130

128-
(( $#skip_test )) && { print -r -- "1..0 # SKIP $skip_test"; return; }
131+
# WARNING: The remainder of this anonymous function will run with the test's options in effect
129132

130-
# Check the data declares $PREBUFFER or $BUFFER.
131-
[[ -z $PREBUFFER && -z $BUFFER ]] && { echo >&2 "Bail out! On ${(qq)1}: Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank"; return 1; }
132-
# Check the data declares $expected_region_highlight.
133-
(( $+expected_region_highlight == 0 )) && { echo >&2 "Bail out! On ${(qq)1}: 'expected_region_highlight' is not declared."; return 1; }
133+
(( $#skip_test )) && { print -r -- "1..0 # SKIP $skip_test"; return; }
134134

135-
# Set sane defaults for ZLE variables
136-
: ${CURSOR=$#BUFFER} ${PENDING=0} ${WIDGET=z-sy-h-test-harness-test-widget}
135+
# Check the data declares $PREBUFFER or $BUFFER.
136+
[[ -z $PREBUFFER && -z $BUFFER ]] && { echo >&2 "Bail out! On ${(qq)1}: Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank"; return 1; }
137+
# Check the data declares $expected_region_highlight.
138+
(( $+expected_region_highlight == 0 )) && { echo >&2 "Bail out! On ${(qq)1}: 'expected_region_highlight' is not declared."; return 1; }
137139

138-
# Process the data.
139-
_zsh_highlight
140+
# Set sane defaults for ZLE variables
141+
: ${CURSOR=$#BUFFER} ${PENDING=0} ${WIDGET=z-sy-h-test-harness-test-widget}
142+
143+
# Process the data.
144+
_zsh_highlight
145+
}
146+
unset ARG
140147

141148
if (( unsorted )); then
142149
region_highlight=("${(@n)region_highlight}")

0 commit comments

Comments
 (0)