diff --git a/test/README.md b/test/README.md index b13a2da..2344220 100644 --- a/test/README.md +++ b/test/README.md @@ -7,6 +7,7 @@ Vimwiki functionality. It is based on the following tools: - [Vader](https://github.com/junegunn/vader.vim) - [Vint](https://github.com/Kuniwak/vint) + ## Resources - [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) - [Other projects](https://github.com/junegunn/vader.vim/wiki/Projects-using-Vader) + ## Building Docker Image To build the Docker image run `docker build -t vimwiki .` from the Vimwiki repository root (same location as the Dockerfile). + ## Running Tests ### 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 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 - `$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) + ## Known Issues 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/`. - [Vader Issue #199](https://github.com/junegunn/vader.vim/issues/199) + ## Notable Vim patches - `v7.3.831` `getbufvar` added a default value diff --git a/test/issue_markdown.vader b/test/issue_markdown.vader index e633ee9..ac0b91d 100644 --- a/test/issue_markdown.vader +++ b/test/issue_markdown.vader @@ -8,8 +8,12 @@ Include: vader_includes/vader_setup.vader + +################################################################################ Execute (Log): Log '#949 create link bug with Chinese characters' + file wiki_test.md + call SetSyntax('markdown') Given vimwiki (Madarin with vimwiki Yeeepy): 你 @@ -33,8 +37,11 @@ Expect (all WORDS are links): [aaaaa你们好啊](aaaaa你们好啊) +################################################################################ Execute (Log): 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): 1. item1 @@ -57,8 +64,11 @@ Expect (Renumber all): 4. item3 +################################################################################ Execute (Log): Log '#899 conceallevel is setted globally when editing a wiki file (PR #900)' + file wiki_test.md + call SetSyntax('markdown') Given vimwiki (Void): @@ -93,8 +103,10 @@ Execute (conceal): endif +################################################################################ Execute (Log): Log 'PR #528: Add option |g:vimwiki_create_link| to prevent link creation' + call SetSyntax('markdown') Given vimwiki (Link): Link diff --git a/test/run_tests.sh b/test/run_tests.sh index 89d5967..9229dc8 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -7,42 +7,49 @@ o_error=0 printHelp() { - echo "Usage: $0 [OPTIONS]" - echo "" - echo "Runs Vimwiki Vader tests or Vint in a Docker container" - echo "" - echo "-h Print help message" - echo "" - echo "-n Specify vim/nvim version to run tests for." - echo " Multiple versions can be specified by quoting the value and" - echo " separating versions with a space. E.g. -n \"vim1 vim2\"." - echo " Default is all available versions." - echo "" - echo "-l List available versions that can be used with the '-n' option" - echo "" - echo "-t Select test type: 'vader', 'vint', or 'all'" - echo "" - echo "-o Comma seperated list of tests to run." - echo " E.g. -o \"list_margin,command_toc\"" - echo "" - echo "-v Turn on verbose output." + cat << ' EOF' | sed -e 's/^ //' + Usage: bash run_tests.sh [OPTIONS] + + Runs Vimwiki Vader tests or Vint in a Docker container + + -h (Help) Print help message + + -n (versioN) Specify vim/nvim version to run tests for. + Multiple versions can be specified by quoting the value and + separating versions with a space. E.g. -n "vim1 vim2". + Default is all available versions. + + -f (File) Comma seperated list of tests to run. + E.g. -o "list_margin,command_toc" + + -l (List) list available versions that can be used with the '-n' option + + -t (Type) Select test type: 'vader', 'vint', or 'all' + + -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 } printVersions() { - # print the names of all vim/nvim versions + # Print the names of all vim/nvim versions getVers exit 0 } runVader() { + # Run 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" res="test/*" else - IFS=',' read -ra TEST <<< "$only" + IFS=',' read -ra TEST <<< "$file_test" for i in "${TEST[@]}"; do if [[ -f "$i" ]]; then res="$res test/${i}" @@ -57,26 +64,27 @@ runVader() { fi done 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 - echo "" - echo "Running version: $v" + echo -e "\nRunning version: $v" vim="/vim-build/bin/$v -u test/vimrc -i NONE" test_cmd="for VF in ${ind}; do $vim \"+Vader! \$VF\"; done" 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 docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \ /bin/bash -c "$test_cmd" 2>&1 | vader_filter | vader_color 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 done return $o_error @@ -93,10 +101,11 @@ getVers() { } vader_filter() { + # Filter Vader Stdout local err=0 while read -r; do + # Print only possible error cases if [[ "$verbose" == 0 ]]; then - # only print possible error cases if [[ "$REPLY" = *'docker:'* ]] || \ [[ "$REPLY" = *'Starting Vader:'* ]] || \ [[ "$REPLY" = *'Vader error:'* ]] || \ @@ -178,12 +187,12 @@ type="all" verbose=0 # only run these tests -only="" +file_test="" # docker flags 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 h ) printHelp @@ -200,8 +209,8 @@ while getopts ":hvn:lt:o:" opt; do t ) type="$OPTARG" ;; - o ) - only="$OPTARG" + f ) + file_test="$OPTARG" ;; \? ) echo "Invalid option: $OPTARG" 1>&2