From 038409c10d553d363263f585f14888c06e9d1add Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Sat, 4 Nov 2017 11:19:00 -0500 Subject: [PATCH] tests: Run tests with WARN_CREATE_GLOBAL --- highlighters/main/test-data/commmand-parameter.zsh | 2 +- highlighters/main/test-data/path-dollared-word2.zsh | 2 +- tests/README.md | 3 +++ tests/test-highlighting.zsh | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/highlighters/main/test-data/commmand-parameter.zsh b/highlighters/main/test-data/commmand-parameter.zsh index fb43e9e..355f890 100644 --- a/highlighters/main/test-data/commmand-parameter.zsh +++ b/highlighters/main/test-data/commmand-parameter.zsh @@ -27,7 +27,7 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -x=/usr/bin/env +local x=/usr/bin/env BUFFER='$x "argument"' expected_region_highlight=( diff --git a/highlighters/main/test-data/path-dollared-word2.zsh b/highlighters/main/test-data/path-dollared-word2.zsh index 3485b45..d1c34af 100644 --- a/highlighters/main/test-data/path-dollared-word2.zsh +++ b/highlighters/main/test-data/path-dollared-word2.zsh @@ -27,7 +27,7 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -lambda="''" +local lambda="''" touch \$lambda BUFFER=': \$lambda' diff --git a/tests/README.md b/tests/README.md index 5526612..11c35fc 100644 --- a/tests/README.md +++ b/tests/README.md @@ -21,6 +21,9 @@ point will not fail the test), and `$todo` is used as the explanation. **Note**: `$region_highlight` uses the same `"$i $j $style"` syntax but interprets the indexes differently. +**Note**: Tests are run with `setopt NOUNSET WARN_CREATE_GLOBAL`, so any +variables the test creates must be declared local. + **Isolation**: Each test is run in a separate subshell, so any variables, aliases, functions, etc., it defines will be visible to the tested code (that computes `$region_highlight`), but will not affect subsequent tests. The diff --git a/tests/test-highlighting.zsh b/tests/test-highlighting.zsh index a9210ae..9731d8d 100755 --- a/tests/test-highlighting.zsh +++ b/tests/test-highlighting.zsh @@ -29,7 +29,7 @@ # ------------------------------------------------------------------------------------------------- -setopt NOUNSET +setopt NO_UNSET WARN_CREATE_GLOBAL # Check an highlighter was given as argument. [[ -n "$1" ]] || {