commit 4f648b6567a813646517fcb29a7bbd925d6d3d5c
parent eb26a66be551f82dbeaa7bfbbd424960ef6a6fae
Author: Rane Brown <rane.brown@gmail.com>
Date: Fri, 13 Dec 2019 19:58:08 -0700
Modify how tests are run to improve overall speed.
A Vader issue causes problems with the test results when using the
location list. Because of this the tests were modified to run 1 test
file per vim instance instead of running all tests in a single vim
instance. This resulted in signficant slow down in test execution time.
To speed up execution time only specific tests are run individually now.
Diffstat:
6 files changed, 83 insertions(+), 67 deletions(-)
diff --git a/test/Readme.md b/test/Readme.md
@@ -50,3 +50,6 @@ plugin source files. For more information run `./run_tests.sh -h`.
`Vim: Error reading input, exiting...`
- Probably need to look into this more and determine if the issue is Vader,
Neovim, or Docker.
+2. Vader does not play nice with the location list. Tests that use the location
+ list should be placed in `independent_runs/`.
+ - [Vader Issue #199](https://github.com/junegunn/vader.vim/issues/199)
diff --git a/test/independent_runs/search.vader b/test/independent_runs/search.vader
@@ -0,0 +1,66 @@
+Include: vader_setup
+
+Execute (Setup search testing wrapper):
+ function! TestSearch(search_command, test_name)
+ " Note: after each search, the location list of the current window (0)
+ " will contain the search results. A non-empty list indicates success.
+ " Search for a single word (a pattern with no spaces)
+ redir => output
+ silent execute a:search_command
+ redir END
+ Assert !empty(getloclist(0)), a:test_name.": no location list result"
+ Assert match(output, '\d of \d') > -1, a:test_name.": no result message"
+
+ " Tests that VimwikiSearch is quoting the pattern correctly.
+ " If not, Vim will see anything after the first space in the pattern
+ " as a file name and attempt to open it.
+ Assert match(output, 'Cannot open file') == -1, "'open file': unquoted pattern?"
+
+ return output
+ endfunction
+
+Execute (Search test wiki):
+ " Open test wiki
+ edit test/resources/testwiki/index.wiki
+
+ " Make sure we opened the test wiki successfully by checking the
+ " title (first line) and filetype.
+ AssertEqual "= Test Wiki =", getline(1)
+ AssertEqual "vimwiki", &filetype
+
+
+ call TestSearch('VimwikiSearch foo', 'pattern with no spaces')
+ call TestSearch('VimwikiSearch foo bar', 'pattern with spaces')
+ call TestSearch('VimwikiSearch foo\bar', 'pattern with ''\''')
+ call TestSearch('VimwikiSearch baz{13}', 'pattern with literal {}')
+ call TestSearch('VimwikiSearch /\vbuz{5}/', 'proper regex')
+ call TestSearch('VWS foo bar', 'use VWS abbreviation')
+
+Execute (Search space path wiki):
+ " Open wiki with spaces in path to test fname escaping
+ edit test/resources/testwiki\ space/index.wiki
+
+ " Make sure we opened the space path wiki successfully
+ AssertEqual "= Space Path Wiki =", getline(1)
+
+ call TestSearch('VimwikiSearch foo', 'simple search in space path wiki')
+
+Execute (Search failure message):
+ " Important note: No search tests will succeed after this.
+ " The failed search will cause a Vim error to be thrown and
+ " any search with lvimgrep within Vader will result in an
+ " empty location list and empty messages queue. It is
+ " difficult to tell if the search itself is failing or if it
+ " is just an inability to view the results.
+
+ " Open test wiki again
+ edit test/resources/testwiki/index.wiki
+
+ " Now test a negative search and make sure we are returning
+ " the expected VimWiki error.
+ redir => output
+ silent VimwikiSearch not_exist
+ redir END
+ Assert match(output, 'VimwikiSearch: No match found.') > -1, "expected custom error"
+
+Include: vader_teardown
diff --git a/test/independent_runs/vader_setup b/test/independent_runs/vader_setup
@@ -0,0 +1 @@
+../vader_includes/vader_setup.vader
+\ No newline at end of file
diff --git a/test/independent_runs/vader_teardown b/test/independent_runs/vader_teardown
@@ -0,0 +1 @@
+../vader_includes/vader_teardown.vader
+\ No newline at end of file
diff --git a/test/run_tests.sh b/test/run_tests.sh
@@ -36,11 +36,20 @@ runVader() {
echo ""
echo "Running version: $v"
vim="/vim-build/bin/$v -u test/vimrc -i NONE"
- test_cmd="for VF in test/*.vader; do $vim \"+Vader! \$VF\"; done"
+ test_cmd="for VF in test/independent_runs/*.vader; do $vim \"+Vader! \$VF\"; done"
+
set -o pipefail
+
+ # tests that must be run in individual vim instances
+ # see README.md for more information
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
/bin/bash -c "$test_cmd" 2>&1 | vader_filter | vader_color
+
+ # remaining tests
+ docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
+ "$v" -u test/vimrc -i NONE "+Vader! test/*" 2>&1 | vader_filter | vader_color
set +o pipefail
+
done
}
diff --git a/test/search.vader b/test/search.vader
@@ -1,66 +0,0 @@
-Include: vader_includes/vader_setup.vader
-
-Execute (Setup search testing wrapper):
- function! TestSearch(search_command, test_name)
- " Note: after each search, the location list of the current window (0)
- " will contain the search results. A non-empty list indicates success.
- " Search for a single word (a pattern with no spaces)
- redir => output
- silent execute a:search_command
- redir END
- Assert !empty(getloclist(0)), a:test_name.": no location list result"
- Assert match(output, '\d of \d') > -1, a:test_name.": no result message"
-
- " Tests that VimwikiSearch is quoting the pattern correctly.
- " If not, Vim will see anything after the first space in the pattern
- " as a file name and attempt to open it.
- Assert match(output, 'Cannot open file') == -1, "'open file': unquoted pattern?"
-
- return output
- endfunction
-
-Execute (Search test wiki):
- " Open test wiki
- edit test/resources/testwiki/index.wiki
-
- " Make sure we opened the test wiki successfully by checking the
- " title (first line) and filetype.
- AssertEqual "= Test Wiki =", getline(1)
- AssertEqual "vimwiki", &filetype
-
-
- call TestSearch('VimwikiSearch foo', 'pattern with no spaces')
- call TestSearch('VimwikiSearch foo bar', 'pattern with spaces')
- call TestSearch('VimwikiSearch foo\bar', 'pattern with ''\''')
- call TestSearch('VimwikiSearch baz{13}', 'pattern with literal {}')
- call TestSearch('VimwikiSearch /\vbuz{5}/', 'proper regex')
- call TestSearch('VWS foo bar', 'use VWS abbreviation')
-
-Execute (Search space path wiki):
- " Open wiki with spaces in path to test fname escaping
- edit test/resources/testwiki\ space/index.wiki
-
- " Make sure we opened the space path wiki successfully
- AssertEqual "= Space Path Wiki =", getline(1)
-
- call TestSearch('VimwikiSearch foo', 'simple search in space path wiki')
-
-Execute (Search failure message):
- " Important note: No search tests will succeed after this.
- " The failed search will cause a Vim error to be thrown and
- " any search with lvimgrep within Vader will result in an
- " empty location list and empty messages queue. It is
- " difficult to tell if the search itself is failing or if it
- " is just an inability to view the results.
-
- " Open test wiki again
- edit test/resources/testwiki/index.wiki
-
- " Now test a negative search and make sure we are returning
- " the expected VimWiki error.
- redir => output
- silent VimwikiSearch not_exist
- redir END
- Assert match(output, 'VimwikiSearch: No match found.') > -1, "expected custom error"
-
-Include: vader_includes/vader_teardown.vader