Test: 1/Fix some interdependencies 2/replace -o -> -f

1/ Fix interdependencies: any test can run alone
2/ Replace command line -o by -f
3/ As usual makesome formating, don't hate me if merge conflicting ..
This commit is contained in:
Tinmarino 2020-07-25 02:05:59 -04:00
parent ac38bb2f09
commit 81c67f97e4
3 changed files with 67 additions and 36 deletions

View File

@ -7,6 +7,7 @@ Vimwiki functionality. It is based on the following tools:
- [Vader](https://github.com/junegunn/vader.vim) - [Vader](https://github.com/junegunn/vader.vim)
- [Vint](https://github.com/Kuniwak/vint) - [Vint](https://github.com/Kuniwak/vint)
## Resources ## Resources
- [Vim patches](http://ftp.vim.org/pub/vim/patches/) - [Vim patches](http://ftp.vim.org/pub/vim/patches/)
@ -16,11 +17,13 @@ Vimwiki functionality. It is based on the following tools:
- [ale](https://github.com/w0rp/ale/tree/master/test) - [ale](https://github.com/w0rp/ale/tree/master/test)
- [Other projects](https://github.com/junegunn/vader.vim/wiki/Projects-using-Vader) - [Other projects](https://github.com/junegunn/vader.vim/wiki/Projects-using-Vader)
## Building Docker Image ## Building Docker Image
To build the Docker image run `docker build -t vimwiki .` from the Vimwiki To build the Docker image run `docker build -t vimwiki .` from the Vimwiki
repository root (same location as the Dockerfile). repository root (same location as the Dockerfile).
## Running Tests ## Running Tests
### Manual Steps ### Manual Steps
@ -43,7 +46,12 @@ automatically run all tests for all installed vim versions. The vim/nvim
versions are parsed from the Dockerfile. This script will also run `Vint` for all versions are parsed from the Dockerfile. This script will also run `Vint` for all
plugin source files. For more information run `./run_tests.sh -h`. plugin source files. For more information run `./run_tests.sh -h`.
## Inside the container
## Writing Tests
You are advice to write tests at the top of the file where you want to include it because some `Execute` can have some side effect making it hard to debug
### Inside the container
- `$USER` -> `vimtest` : unprivileged => very hard to mess up things - `$USER` -> `vimtest` : unprivileged => very hard to mess up things
- `$HOME` -> `/home/vimtest` : but it is readonly ! - `$HOME` -> `/home/vimtest` : but it is readonly !
@ -51,6 +59,7 @@ plugin source files. For more information run `./run_tests.sh -h`.
For more information, read the [base docker image](https://github.com/tweekmonster/vim-testbed) For more information, read the [base docker image](https://github.com/tweekmonster/vim-testbed)
## Known Issues ## Known Issues
1. neovim v0.2.x does not work correctly with Vader output from the docker 1. neovim v0.2.x does not work correctly with Vader output from the docker
@ -62,6 +71,7 @@ For more information, read the [base docker image](https://github.com/tweekmonst
list should be placed in `independent_runs/`. list should be placed in `independent_runs/`.
- [Vader Issue #199](https://github.com/junegunn/vader.vim/issues/199) - [Vader Issue #199](https://github.com/junegunn/vader.vim/issues/199)
## Notable Vim patches ## Notable Vim patches
- `v7.3.831` `getbufvar` added a default value - `v7.3.831` `getbufvar` added a default value

View File

@ -8,8 +8,12 @@
Include: vader_includes/vader_setup.vader Include: vader_includes/vader_setup.vader
################################################################################
Execute (Log): Execute (Log):
Log '#949 <Enter> create link bug with Chinese characters' Log '#949 <Enter> create link bug with Chinese characters'
file wiki_test.md
call SetSyntax('markdown')
Given vimwiki (Madarin with vimwiki Yeeepy): Given vimwiki (Madarin with vimwiki Yeeepy):
@ -33,8 +37,11 @@ Expect (all WORDS are links):
[aaaaa你们好啊](aaaaa你们好啊) [aaaaa你们好啊](aaaaa你们好啊)
################################################################################
Execute (Log): Execute (Log):
Log '#735 Fix off-by-one error in get_next_line and get_prev_line' Log '#735 Fix off-by-one error in get_next_line and get_prev_line'
file wiki_test.md
call SetSyntax('markdown')
Given vimwiki (P#735 -> I#407): Given vimwiki (P#735 -> I#407):
1. item1 1. item1
@ -57,8 +64,11 @@ Expect (Renumber all):
4. item3 4. item3
################################################################################
Execute (Log): Execute (Log):
Log '#899 conceallevel is setted globally when editing a wiki file (PR #900)' Log '#899 conceallevel is setted globally when editing a wiki file (PR #900)'
file wiki_test.md
call SetSyntax('markdown')
Given vimwiki (Void): Given vimwiki (Void):
@ -93,8 +103,10 @@ Execute (conceal):
endif endif
################################################################################
Execute (Log): Execute (Log):
Log 'PR #528: Add option |g:vimwiki_create_link| to prevent link creation' Log 'PR #528: Add option |g:vimwiki_create_link| to prevent link creation'
call SetSyntax('markdown')
Given vimwiki (Link): Given vimwiki (Link):
Link Link

View File

@ -7,42 +7,49 @@
o_error=0 o_error=0
printHelp() { printHelp() {
echo "Usage: $0 [OPTIONS]" cat << ' EOF' | sed -e 's/^ //'
echo "" Usage: bash run_tests.sh [OPTIONS]
echo "Runs Vimwiki Vader tests or Vint in a Docker container"
echo "" Runs Vimwiki Vader tests or Vint in a Docker container
echo "-h Print help message"
echo "" -h (Help) Print help message
echo "-n Specify vim/nvim version to run tests for."
echo " Multiple versions can be specified by quoting the value and" -n (versioN) Specify vim/nvim version to run tests for.
echo " separating versions with a space. E.g. -n \"vim1 vim2\"." Multiple versions can be specified by quoting the value and
echo " Default is all available versions." separating versions with a space. E.g. -n "vim1 vim2".
echo "" Default is all available versions.
echo "-l List available versions that can be used with the '-n' option"
echo "" -f (File) Comma seperated list of tests to run.
echo "-t Select test type: 'vader', 'vint', or 'all'" E.g. -o "list_margin,command_toc"
echo ""
echo "-o Comma seperated list of tests to run." -l (List) list available versions that can be used with the '-n' option
echo " E.g. -o \"list_margin,command_toc\""
echo "" -t (Type) Select test type: 'vader', 'vint', or 'all'
echo "-v Turn on verbose output."
-v (Verbose) Turn on verbose output.
E.g. bash run_tests.sh -v -t vader -n "vim_7.4.1099 vim_8.1.0519" -f link_creation.vader,issue_markdown.vader
EOF
exit 0 exit 0
} }
printVersions() { printVersions() {
# print the names of all vim/nvim versions # Print the names of all vim/nvim versions
getVers getVers
exit 0 exit 0
} }
runVader() { runVader() {
# Run Vader tests
echo "Starting Docker container and Vader tests." echo "Starting Docker container and Vader tests."
if [[ -z $only ]]; then # Parse tests files to execute
if [[ -z $file_test ]]; then
ind="test/independent_runs/*.vader" ind="test/independent_runs/*.vader"
res="test/*" res="test/*"
else else
IFS=',' read -ra TEST <<< "$only" IFS=',' read -ra TEST <<< "$file_test"
for i in "${TEST[@]}"; do for i in "${TEST[@]}"; do
if [[ -f "$i" ]]; then if [[ -f "$i" ]]; then
res="$res test/${i}" res="$res test/${i}"
@ -57,26 +64,27 @@ runVader() {
fi fi
done done
fi fi
echo "Vader: running files: $res and independantly $ind"
# run tests for each specified version # Run tests for each specified version
for v in $vers; do for v in $vers; do
echo "" echo -e "\nRunning version: $v"
echo "Running version: $v"
vim="/vim-build/bin/$v -u test/vimrc -i NONE" vim="/vim-build/bin/$v -u test/vimrc -i NONE"
test_cmd="for VF in ${ind}; do $vim \"+Vader! \$VF\"; done" test_cmd="for VF in ${ind}; do $vim \"+Vader! \$VF\"; done"
set -o pipefail set -o pipefail
# tests that must be run in individual vim instances # Run Fast tests
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
"$v" -u test/vimrc -i NONE "+Vader! ${res}" 2>&1 | vader_filter | vader_color
o_error=$(( $o_error | $? ))
# Run Tests that must be run in individual vim instances
# see README.md for more information # see README.md for more information
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \ docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
/bin/bash -c "$test_cmd" 2>&1 | vader_filter | vader_color /bin/bash -c "$test_cmd" 2>&1 | vader_filter | vader_color
o_error=$(( $o_error | $? )) o_error=$(( $o_error | $? ))
# remaining tests
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
"$v" -u test/vimrc -i NONE "+Vader! ${res}" 2>&1 | vader_filter | vader_color
o_error=$(( $o_error | $? ))
set +o pipefail set +o pipefail
done done
return $o_error return $o_error
@ -93,10 +101,11 @@ getVers() {
} }
vader_filter() { vader_filter() {
# Filter Vader Stdout
local err=0 local err=0
while read -r; do while read -r; do
# Print only possible error cases
if [[ "$verbose" == 0 ]]; then if [[ "$verbose" == 0 ]]; then
# only print possible error cases
if [[ "$REPLY" = *'docker:'* ]] || \ if [[ "$REPLY" = *'docker:'* ]] || \
[[ "$REPLY" = *'Starting Vader:'* ]] || \ [[ "$REPLY" = *'Starting Vader:'* ]] || \
[[ "$REPLY" = *'Vader error:'* ]] || \ [[ "$REPLY" = *'Vader error:'* ]] || \
@ -178,12 +187,12 @@ type="all"
verbose=0 verbose=0
# only run these tests # only run these tests
only="" file_test=""
# docker flags # docker flags
flags=(--rm -v "$PWD/../:/testplugin" -v "$PWD/../test:/home" -w /testplugin vimwiki) flags=(--rm -v "$PWD/../:/testplugin" -v "$PWD/../test:/home" -w /testplugin vimwiki)
while getopts ":hvn:lt:o:" opt; do while getopts ":hvn:lt:f:" opt; do
case ${opt} in case ${opt} in
h ) h )
printHelp printHelp
@ -200,8 +209,8 @@ while getopts ":hvn:lt:o:" opt; do
t ) t )
type="$OPTARG" type="$OPTARG"
;; ;;
o ) f )
only="$OPTARG" file_test="$OPTARG"
;; ;;
\? ) \? )
echo "Invalid option: $OPTARG" 1>&2 echo "Invalid option: $OPTARG" 1>&2