Test: Refactor: Normalize names and behavior

This commit is contained in:
Tinmarino 2020-08-09 16:13:53 -04:00
parent 4b041a606a
commit 7144df6b96
19 changed files with 261 additions and 113 deletions

View File

@ -26,16 +26,17 @@ env:
- VIM_VERSION=vint
- VIM_VERSION=vim_7.3.429
- VIM_VERSION=nvim_0.3.8
# More
- VIM_VERSION=vim_7.4.1099
- VIM_VERSION=vim_7.4.1546
- VIM_VERSION=vim_8.0.0027
- VIM_VERSION=vim_8.1.0519
# More
- VIM_VERSION=vim_7.4.1099 PATTERN='[a-k]*.vader'
- VIM_VERSION=vim_7.4.1546 PATTERN='l*.vader'
- VIM_VERSION=vim_8.0.0027 PATTERN='[m-z]*.vader'
script:
# Run All tests
- pushd test
- if [[ "$VIM_VERSION" == 'vint' ]]; then bash run_tests.sh -v -t vint;
elif [[ ! -z "$PATTERN" ]]; then bash run_tests.sh -v -t vader -n "$VIM_VERSION" -f "$PATTERN";
else bash run_tests.sh -v -t vader -n "$VIM_VERSION";
fi
- popd

View File

@ -77,7 +77,8 @@ Execute (:VimwikiGoto + Completion in directory):
AssertEqual 0, len(l_complete5)
Execute (Clean):
Log "End: Clean"
call DeleteFile("$HOME/testmarkdown/dir1/dir2/test_goto_file.md")
call DeleteFile("$HOME/testmarkdown/index.md")
call system("rm $HOME/testmarkdown/dir1")
# vim: sw=2 foldmethod=indent foldlevel=30 foldignore=

View File

@ -29,5 +29,7 @@ Do (At Index: Create and goto markdownfile):
dd
:call DeleteFile('mdfile.md')\<Cr>
Execute (Clean):
call DeleteFile("$HOME/testmarkdown/index.md")
# vim: sw=2:foldmethod=marker:foldlevel=30:foldignore=:

View File

@ -241,6 +241,7 @@ Execute (Edit TestHtml Wiki):
Do (Markdwon with %plainhtml):
:edit $HOME/testwiki/TestHtml.wiki\<CR>
:normal ggdG\<Cr>
i%plainhtml<div id="test">\<CR>
my paragraph\<CR>
%plainhtml</div>\<CR>\<Esc>

View File

@ -37,7 +37,8 @@ Do (Get RSS feed):
:write
Expect (RSS):
<?xml version="1.0" encoding="UTF-8" ?>
# TODO the next line is deleted with -Es
# <?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Diary</title>

View File

@ -1,3 +1,8 @@
# Maps
# TODO make it without side effects
# -- Use the normal vimwiki or reset it
# 0 Configure {{{1
##################
@ -26,7 +31,23 @@ Execute (Configure: Set vimwiki list to markdown resource):
let g:vimwiki_ext2syntax = {'.md': 'markdown'}
Log "Reload vimwiki <- vader_setup.vader"
call ReloadVimwiki()
nmapclear
" UNlet what can be
for i in ['g:vimwiki_commentstring',
\ 'b:did_ftplugin',
\ 'g:loaded_vimwiki',
\ 'g:vimwiki_global_vars',
\ 'g:vimwiki_wikilocal_vars',
\ 'g:vimwiki_syntax_variables',
\ ]
if exists(i)
exe 'unlet ' . i
endif
endfor
" Source plugin: Go
runtime! plugin/vimwiki.vim
Execute (Assert: 2 wiki in Index):
AssertEqual 2, len(vimwiki_wikilocal_vars)
@ -304,7 +325,15 @@ Given vimwiki (Completion list #813 {{{3):
Do (Insert a list item and complete):
Go
* comp\<C-n>\<Down>\<Cr>
* comp\<C-n>\<C-n>\<Cr>\<Esc>
# -Es -> Delete trailing *
:let mode = mode(1)\<Cr>
:Log 'Mode : ' .mode\<Cr>
:if mode ==# 'ce' || mode ==# 'cv'\<Cr>
try\<Cr>
g/^\* \?$/d\<Cr>
endtry\<Cr>
endif\<Cr>
Expect (With a completion but no new item):
complete1

View File

@ -59,4 +59,4 @@ Execute (Search failure message):
redir => output
silent VimwikiSearch not_exist
redir END
Assert match(output, 'VimwikiSearch: No match found.') > -1, "expected custom error"
Assert match(output, 'Vimwiki: Search: No match found.') > -1, "expected custom error"

View File

@ -4,11 +4,18 @@
# Thanks to all contributors with issues and pull request on github
#
Given vimwiki (a):
a
Execute (Set filename wiki_test.md):
file wiki_test.md
Expect (a):
a
################################################################################
Execute (Log):
Log '#915 Vimwiki Markdown Blockquote Syntax issue'
file wiki_test.md
call SetSyntax('markdown')
Given vimwiki (One blockquote):
@ -46,7 +53,6 @@ Execute (no JJ && Assert for Version > 7.3):
################################################################################
Execute (Log):
Log '#949 <Enter> create link bug with Chinese characters'
file wiki_test.md
call SetSyntax('markdown')
Given vimwiki (Madarin with vimwiki Yeeepy):
@ -101,7 +107,6 @@ Expect (Renumber all):
################################################################################
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):
@ -163,3 +168,10 @@ Do (No link: <CR><CR>):
:call vimwiki#vars#set_global('markdown_create_link', 0)
\<CR>\<CR>
:AssertEqual expand('%:t'), 'main.md'\<CR>
Expect (Link):
[Link](Link)
Execute (wipeout):
" This solves many things
file /testplugin/[Vader-workbench]

View File

@ -0,0 +1,51 @@
# See Issue #580
Given vimwiki (Void):
Tabnext
Execute (Set fold method):
let g:vimwiki_folding = 'expr:quick'
call ReloadVimwiki()
Execute (Expect < 0.5 second delay: Issue #580):
let mode = mode(1)
Log 'Mode : ' .mode
if mode ==# 'ce' || mode ==# 'cv' " -es (silent ex mode)
Log 'Skiped: Tabedit and tabnext are not working weel with -Es'
else
Log 'Prepare: Edit: mode: ' . mode
edit /testplugin/test/resources/delay.wiki
Log 'Prepare: Assert'
AssertEqual 'default', vimwiki#vars#get_wikilocal('syntax')
Log 'Prepare: Goto 50%'
normal! 50%
# "TODO set ft and set wiki syntax or this error (no fold found)
# "normal! zozo
Log 'Run: tabedit'
let start = reltime()
tabedit
let end = str2float(reltimestr(reltime(start)))
Log 'Verify redraw'
Log 'Elapsed time Tabedit = ' . string(end)
Assert end < 0.5, 'Redraw Took longer than expected: ' . string(end) . ' seconds'
Log 'Run: redraw'
let start = reltime()
tabprev
redraw
let end = str2float(reltimestr(reltime(start)))
Log 'Verify redraw'
Log 'Elapsed time redraw = ' . string(end)
Assert end < 0.5, 'Redraw Took longer than expected: ' . string(end) . ' seconds'
endif
Execute (Reset variables):
call DeleteFile('/testplugin/test/resources/delay.wiki')
let g:vimwiki_folding = ''
call ReloadVimwiki()
Expect vimwiki (Tabnext):
Tabnext

View File

@ -72,6 +72,8 @@ Do (Enter link):
A__HERE3__\<Esc>
ggjjj\<Cr>
A__HERE4__\<Esc>
:AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')\<Cr>
Expect vimwiki (Good anchor with link navigation):
[A link B](#a-link-b)
@ -299,7 +301,7 @@ Expect (Just Contents/test1 got the second shot):
- [filenew](filenew) first shot
Execute (Delete filenew buffer):
bd! /testplugin/filenew.md
call DeleteFile('/testplugin/filenew.md')
Do (Navigate with <Tab> comeback with <Bs> too far):
\<Tab>

View File

@ -200,6 +200,11 @@ Do (Check in_tmp):
jj\<Cr>
:AssertEqual expand('%'), '/tmp/in_tmp.wiki'\<Cr>
Execute(Clean: temporary):
call ReloadVimwiki()
call DeleteFile('$HOME/in_home1.md')
call DeleteFile('~/in_home2.md')
call DeleteFile('/tmp/in_tmp.md')
# Link with dot {{{1
####################
@ -368,4 +373,7 @@ Expect (Mediawiki links):
[[file.md]]
[[file.mw]]
Execute(Clean: Icreated many temporary wiki):
call ReloadVimwiki()
# vim: foldmethod=marker foldlevel=30

View File

@ -7,6 +7,7 @@
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
set sw=8
# 1 VimwikiGenerateLinks {{{1
##########################
@ -195,7 +196,7 @@ Expect (diary index generated):
Execute (Clean):
Log "End: Clean"
call DeleteFile("$HOME/testmarkdown/index.md")
call DeleteFile('$HOME/testmarkdown/diary/2019-12-10.md')
call DeleteFile('$HOME/testmarkdown/diary/2019-07-13.md')
call DeleteFile('$HOME/testmarkdown/diary/2019-03-01.md')

View File

@ -36,10 +36,21 @@ Execute (Create 3 files):
Do (Testing Old buffer has been wiped out {{{2):
:edit $HOME/testmarkdown/Test-Rename-Completion.md\<Cr>
:Log 'Get current Buffer'\<Cr>
:let buf_old = bufnr('%')\<Cr>
:Log 'Is this wiki 2'\<Cr>
:AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')\<Cr>
:Log 'Delete for loosers'\<Cr>
:call DeleteFile('$HOME/testmarkdown/Test-Rename-new1.md')\<Cr>
:Log 'Rewrite ...'\<Cr>
:call WriteMe()\<Cr>
:Log 'Rename 1'\<Cr>
:VimwikiRenameFile Test-Rename-new1\<Cr>
:Log 'Assert 1'\<Cr>
:AssertEqual 'Test-Rename-new1', expand('%:t:r')\<Cr>
:Log 'Rename 2'\<Cr>
:VimwikiRenameFile Test-Rename-Completion\<Cr>
:Log 'Assert 2'\<Cr>
:AssertEqual expand('%'), $HOME . '/testmarkdown/Test-Rename-Completion.md'\<Cr>
Do (Testing Completion {{{2):
@ -83,6 +94,7 @@ Do (Testing transforward {{{2):
Execute (Delete smaller unit changed {{{2):
call DeleteFile('$HOME/testmarkdown/Test-Rename-new1.md')
call DeleteFile('$HOME/testmarkdown/Test-Rename-zzz.md')
call DeleteFile('$HOME/testmarkdown/dir1/Test-Rename-Completion_2.md')
call DeleteFile('$HOME/testmarkdown/dir1/Test-Rename-2.md')

View File

@ -5,6 +5,7 @@
# Say Hi
echo -en "Starting $(basename $0) for VimWiki\n"
start_time=`date +%s`
# For windows: Cmder bash is appending busybox to the path and
# and a smlll vim is included, so that override the windows path vim
@ -28,8 +29,8 @@ printHelp() {
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"
-f (File) Space separated list of tests to run.
E.g. -o "list_* z_success"
-l (List) list available versions that can be used with the '-n' option
@ -38,7 +39,7 @@ printHelp() {
-v (Verbose) Turn on verbose output.
E.g. On Linux
bash run_tests.sh -v -t vader -n "vim_7.4.1099 vim_8.1.0519" -f link_creation.vader,issue_markdown.vader
bash run_tests.sh -v -t vader -n "vim_7.4.1099 vim_8.1.0519" -f link_creation.vader issue_markdown.vader
E.g. On Windows
bash run_tests.sh -v -t vader -n local -f z_success.vader | cat
EOF
@ -59,12 +60,16 @@ runVader() {
# Parse tests files to execute
if [[ -z $file_test ]]; then
ind="test/independent_runs/*.vader"
res="test/*"
ind="test/independent_runs/*.vader"
res="test/*"
else
IFS=',' read -ra TEST <<< "$file_test"
read -ra TEST <<< "$file_test"
for i in "${TEST[@]}"; do
if [[ -f "$i" ]]; then
if [[ "$i" == "independent_runs/"*"*"* ]]; then
ind="$ind test/${i}"
elif [[ "$i" == *"*"* ]]; then
res="$res test/${i}"
elif [[ -f "$i" ]]; then
res="$res test/${i}"
elif [[ -f "${i}.vader" ]]; then
res="$res test/${i}.vader"
@ -77,11 +82,11 @@ runVader() {
fi
done
fi
echo "Vader: will run files: $res and independently $ind"
# Run tests for each specified version
for v in $vers; do
echo -e "\nRunning version: $v"
echo -e "\n\nRunning version: $v"
echo -e "============================="
# Set local environment variables
if [[ "$v" == "local" ]]; then
@ -98,15 +103,24 @@ runVader() {
export ROOT="$tmp_dir/vader_wiki/"
export HOME="$tmp_dir/vader_wiki/home"
vim="vim"
vim_opt="-u ~/test/vimrc -i NONE"
vim_opt="-u ~/test/vimrc"
else
# Only set dockerized vars
export ROOT="/" # So no if in vimrc
vim="/vim-build/bin/$v"
vim_opt="-u test/vimrc -i NONE"
vim_opt="-u test/vimrc"
fi
set -o pipefail
# Too talkative TODO make a verbose level 1..10 an 1 is not taking vim
#if [[ "$verbose" != 0 ]]; then
# vim_opt+=' -V1'
#fi
# IDK why vim with -Es is returning ! and make fail:
# -- tabnext profiling
# -- map.vim
vim_opt+=' -i NONE -Es '
# set -o pipefail
# Copy the resources to temporary directory
if [[ "$v" == "local" ]]; then
@ -124,41 +138,50 @@ runVader() {
fi
# Run batch of tests
if [[ "$v" == "local" ]]; then
pushd $tmp_dir/vader_wiki/testplugin
if [[ "$res" != "" ]]; then
if [[ "$v" == "local" ]]; then
pushd $tmp_dir/vader_wiki/testplugin
# Run the tests
echo -e "\nStarting vim with Vader"
"$vim" $vim_opt "+Vader! ${res}" 2>&1
err=$(( $err | $? ))
# Run the tests
echo -e "\nStarting Batch Vim/Vader <- $res"
"$vim" $vim_opt "+Vader! ${res}" 2>&1
ret=${PIPESTATUS[1]}; err=$(( $err + $ret ))
echo -e "\nReturned Batch Vim/Vader -> $ret"
popd
else # In docker
echo -e "\nStarting docker with vim with Vader"
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
"$v" $vim_opt "+Vader! ${res}" 2>&1 | vader_filter | vader_color
err=$(( $err | $? ))
popd
else
# In docker
echo -e "\nStarting Independant Vim/Vader <- $res"
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
"$v" $vim_opt "+Vader! ${res}" 2>&1 | vader_filter | vader_color
ret=${PIPESTATUS[1]}; err=$(( $err + $ret ))
echo -e "\nReturned Independant Docker/Vim/Vader -> $ret"
fi
fi
# Run Tests that must be run in individual vim instances
# see README.md for more information
test_cmd="for VF in ${ind}; do $vim $vim_opt \"+Vader! \$VF\"; done"
if [[ "$v" == "local" ]]; then
pushd $tmp_dir/vader_wiki/testplugin
if [[ "$ind" != "" ]]; then
test_cmd="for VF in ${ind}; do $vim $vim_opt \"+Vader! \$VF\"; done"
if [[ "$v" == "local" ]]; then
pushd $tmp_dir/vader_wiki/testplugin
echo "Starting vim with Vader"
bash -c "$test_cmd" 2>&1
err=$(( $err | $? ))
echo -e "\nStarting Vim/Vader <- $test_cmd"
bash -c "$test_cmd" 2>&1
ret=${PIPESTATUS[1]}; err=$(( $err + $ret ))
echo -e "\nReturned Vim/Vader -> $ret"
popd
else # In docker
echo "Starting docker with vim with Vader"
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
/bin/bash -c "$test_cmd" 2>&1 | vader_filter | vader_color
err=$(( $err | $? ))
popd
else # In docker
echo -e "\nStarting Docker/Vim/Vader <- $test_cmd"
docker run -a stderr -e VADER_OUTPUT_FILE=/dev/stderr "${flags[@]}" \
/bin/bash -c "$test_cmd" 2>&1 | vader_filter | vader_color
ret=${PIPESTATUS[1]}; err=$(( $err + $ret ))
echo -e "\nReturned Docker/Vim/Vader -> $ret"
fi
fi
set +o pipefail
#set +o pipefail
# Restore what must (I know it should be refactored in a while)
if [[ "$v" == "local" ]]; then
@ -186,43 +209,44 @@ runVint() {
}
getVers() {
# Get all possible version <- Dockerfile
sed -n 's/.* -name \([^ ]*\) .*/\1/p' ../Dockerfile
}
vader_filter() {
# Filter Vader Stdout
local err=0
while read -r; do
# Keep indentation
local IFS=''
while read -r REPLY; do
# Print only possible error cases
if [[ "$verbose" == 0 ]]; then
if [[ "$REPLY" = *'docker:'* ]] || \
[[ "$REPLY" = *'Starting Vader:'* ]] || \
[[ "$REPLY" = *'Vader error:'* ]] || \
[[ "$REPLY" = *'Vim: Error '* ]]; then
echo "$REPLY"
elif [[ "$REPLY" = *'[EXECUTE] (X)'* ]] || \
[[ "$REPLY" = *'[ EXPECT] (X)'* ]]; then
echo "$REPLY"
if [[ "$REPLY" = *'docker:'* ]] || \
[[ "$REPLY" = *'Starting Vader:'* ]] || \
[[ "$REPLY" = *'Vader error:'* ]] || \
[[ "$REPLY" = *'Vim: Error '* ]]; then
echo "$REPLY"
elif [[ "$REPLY" = *'[EXECUTE] (X)'* ]] || \
[[ "$REPLY" = *'[ EXPECT] (X)'* ]]; then
echo "$REPLY"
err=1
elif [[ "$REPLY" = *'Success/Total:'* ]]; then
success="$(echo -n "$REPLY" | grep -o '[0-9]\+/' | head -n1 | cut -d/ -f1)"
total="$(echo -n "$REPLY" | grep -o '/[0-9]\+' | head -n1 | cut -d/ -f2)"
if [ "$success" -lt "$total" ]; then
err=1
elif [[ "$REPLY" = *'Success/Total:'* ]]; then
success="$(echo -n "$REPLY" | grep -o '[0-9]\+/' | head -n1 | cut -d/ -f1)"
total="$(echo -n "$REPLY" | grep -o '/[0-9]\+' | head -n1 | cut -d/ -f2)"
if [ "$success" -lt "$total" ]; then
err=1
fi
echo "$REPLY"
fi
else
echo "$REPLY"
elif [[ "$verbose" != 0 ]]; then
# just print everything
echo "$REPLY"
fi
done
if [[ "$err" == 1 ]]; then
echo ""
echo "!---------Failed tests detected---------!"
echo "Run with the '-v' flag for verbose output"
echo ""
echo -e "\033[0;31m"
echo -e "!---------Failed tests detected---------!"
echo -e "Run with the '-v' flag for verbose output"
echo -e "\033[0m"
fi
return $err
}
@ -329,24 +353,24 @@ trap exit 1 SIGINT SIGTERM
# Global error return of the script
o_error=0
# select which tests should run
# Select which tests should run
case $type in
"vader" )
runVader ; err=$?
echo "Vader: returned $err"
echo "Main Vader: returned $err"
o_error=$(( $err | $o_error ))
;;
"vint" )
runVint ; err=$?
echo "Vint: returned $err"
echo "Main Vint: returned $err"
o_error=$(( $err | $o_error ))
;;
"all" )
runVint ; err=$?
echo "Vint: returned $err"
echo "Main Vint: returned $err"
o_error=$(( $err | $o_error ))
runVader ; err=$?
echo "Vader: returned $err"
echo "Main Vader: returned $err"
o_error=$(( $err | $o_error ))
;;
* )
@ -354,6 +378,11 @@ case $type in
exit 1
esac
# Calcultate time
end_time=`date +%s`
sec_time=$((end_time - start_time))
printf -v script_time '%dh:%dm:%ds' $(($sec_time/3600)) $(($sec_time%3600/60)) $(($sec_time%60))
# Exit
echo "Script $(basename $0) exiting: $o_error"
echo -ne "Script $(basename $0), in $script_time, Returned -> $o_error\n\n"
exit $o_error

View File

@ -1,30 +0,0 @@
# See Issue #580
Execute (Set fold method):
let g:vimwiki_folding = 'expr:quick'
call ReloadVimwiki()
Execute (Expect < 0.5 second delay: Issue #580):
" prep
edit test/resources/delay.wiki
normal! 50%
# TODO set ft and set wiki syntax or this error (no fold found)
# normal! zozo
tabedit
" run test
let start = reltime()
tabprev
redraw
let end = str2float(reltimestr(reltime(start)))
" cleanup
bdelete test/resources/delay.wiki
" verify
Log 'Elapsed time = ' . string(end)
Assert end < 0.5, 'Took longer than expected: ' . string(end) . ' seconds'
Execute (Reset variables):
let g:vimwiki_folding = ''
call ReloadVimwiki()

View File

@ -1,9 +1,18 @@
" TODO treat if local (see $HOME in all tests)
" TODO mutualise call CopyResources()
" TODO mutualise (to prettify output) mode(1) to check if in -Es or not
" TODO test tabnext in at least one travis job (without -Es)
" TODO (idea) fasten travis difefrent job with the same vimwiki git (-8s)
" Declare tipical Vim preambule
" vint: -ProhibitSetNoCompatible
set nocompatible
filetype plugin indent on
syntax enable
" Usefull var: for one day, making tests on local
let $TPLUGIN = '/testplugin'
let $THOME = $HOME
" Set chrooted virtual runtime path
let rtp=$ROOT.'/rtp.vim'
@ -43,9 +52,12 @@
" Register the 3 wikis
let g:vimwiki_list = [vimwiki_default, vimwiki_markdown, vimwiki_mediawiki]
let g:vimwiki_list_vimrc = [vimwiki_default, vimwiki_markdown, vimwiki_mediawiki]
" Set basic settings
" Avoid more prompt
set nomore
set backspace=indent,eol,start
set wildmode=longest:full,full
set wildmenu
@ -119,8 +131,24 @@
" this is needed if running manually multiple times
nmapclear
unlet g:loaded_vimwiki
source plugin/vimwiki.vim
" UNlet what can be
for i in ['g:vimwiki_commentstring',
\ 'b:did_ftplugin',
\ 'g:loaded_vimwiki',
\ 'g:vimwiki_global_vars',
\ 'g:vimwiki_wikilocal_vars',
\ 'g:vimwiki_syntax_variables',
\ ]
if exists(i)
exe 'unlet ' . i
endif
endfor
" Reset list
let g:vimwiki_list = g:vimwiki_list_vimrc
" Source plugin: Go
runtime! plugin/vimwiki.vim
endfunction
function! ReloadVars()
@ -165,7 +193,7 @@
catch | endtry
" Delete Buffer
try
execute 'bdelete! ' . path
execute 'bwipeout! ' . path
catch | endtry
endfunction