Test: Batchify all && Lint run_test.sh

All tests in the same batch, in other words, no independant test
This commit is contained in:
Tinmarino 2020-08-23 03:42:02 -04:00
parent 817641e551
commit 8e5274b1a2
13 changed files with 75 additions and 175 deletions

View File

@ -6,7 +6,6 @@ Given txt (txt):
txt
Execute (VimWei vars #980):
call CopyResources()
" Set
call UnloadVimwiki()
let wiki = {}
@ -52,7 +51,7 @@ Execute (VimWei vars #980):
bprevious
Log 'Path (Current): ' . getcwd()
Log 'File (Buffer):' . @%
bdelete index.md
bwipeout index.md
" Clean
Log 'Clean up'

View File

@ -5,11 +5,6 @@
# So I used C-L
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Execute (VimwikiGoto buzz_bozz && Assert):
VimwikiIndex 2
VimwikiGoto buzz_bozz
@ -78,7 +73,6 @@ Execute (:VimwikiGoto + Completion in directory):
Execute (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

@ -1,10 +1,5 @@
# Travel thought files
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Given (Void for Accessing other files within vimwiki #979 {{{1):
@ -29,7 +24,4 @@ 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

@ -1,9 +1,5 @@
# Blockquotes in html convertion
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Given (Void):
Execute (Edit TestHtml Wiki):

View File

@ -1,9 +1,5 @@
# Conertion: Wiki -> Html
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
#################################################
Given vimwiki (Comments):
This is some text

View File

@ -1,9 +1,5 @@
# Feature to generate a diray RSS feed (PR #934)
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Given (Void):
Execute (Generate HTML and RSS feed):
@ -21,8 +17,9 @@ Do (Get HTML file):
kdgg
# Delete everything below
jdG
# Save (Not necessary)
:write
# Save (Not necessary) => Actually make rest of batch freeze, do you really want
# to quit buffer
# :write
Expect (RSS link in HTML):
<link rel="alternate" type="application/rss+xml" title="RSS" href="rss.xml">
@ -34,7 +31,7 @@ Do (Get RSS feed):
# Replace pubDate with dummy as it's based on file modification time
:%s@<pubDate>.*</pubDate>@<pubDate>...</pubDate>@g\<CR>
# Save (Not necessary)
:write
# :write
Expect (RSS):
# TODO the next line is deleted with -Es
@ -107,3 +104,6 @@ Expect (RSS):
</item>
</channel>
</rss>
Execute (Clean buffer modification):
edit! $HOME/testwiki/index.wiki

View File

@ -4,9 +4,7 @@
# - buffer list insertion (see: vimwiki#base#update_listing_in_buffer)
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Execute (Reset sw to default (due to batch)):
set sw=8
# 1 VimwikiGenerateLinks {{{1
@ -198,7 +196,6 @@ Expect (diary index generated):
Execute (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

@ -6,11 +6,6 @@
# Create directories I remove at end {{{1
##########################################
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Execute (Mkdir dir1 dir2 dir11 dir12):
call system("mkdir $HOME/testmarkdown/dir1")
call system("mkdir $HOME/testmarkdown/dir1/dir11")

View File

@ -6,63 +6,16 @@
# 0 Configure {{{1
##################
Execute (Configure: Set vimwiki list to markdown resource):
Log "Let mapleader = ,"
let mapleader = ','
Log "Destroy vimrc or previous run heritage"
call DestroyVar('g:vimwiki_list')
call DestroyVar('g:vimwiki_global_vars')
call DestroyVar('g:vimwiki_wikilocal_vars')
Log "Destroy vimrc variable, works better that way"
call DestroyVar('g:vimwiki_default')
call DestroyVar('g:vimwiki_markdown')
call DestroyVar('g:vimwiki_mediawiki')
Log "Declare my vimwiki_list"
let g:vimwiki_list = [{
\ 'path': 'test/resources/testmarkdown',
\ 'syntax': 'markdown',
\ 'ext': '.md'
\ }]
Log "Declare my extension for temporary wiki"
let g:vimwiki_ext2syntax = {'.md': 'markdown'}
Log "Reload vimwiki"
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_syntaxlocal_vars',
\ ]
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)
Execute (VimwikiIndex):
VimwikiIndex 1
VimwikiIndex 2
AssertEqual 1, vimwiki#vars#get_bufferlocal('wiki_nr')
AssertEqual 'vimwiki', &filetype
AssertEqual 'test/resources/testmarkdown/', vimwiki_wikilocal_vars[0]['path']
AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
AssertEqual $HOME . '/testmarkdown/', vimwiki_wikilocal_vars[0]['path']
AssertEqual $HOME . 'testmarkdown/index.md', expand('%')
Execute (Open buzz bozz):
edit test/resources/testmarkdown/buzz_bozz.md
AssertEqual 'test/resources/testmarkdown/buzz_bozz.md', expand('%')
edit $HOME/testmarkdown/buzz_bozz.md
AssertEqual $HOME . '/testmarkdown/buzz_bozz.md', expand('%')
# 1 Global {{{1
###############
@ -72,28 +25,28 @@ Execute (===========================================================):
Do (,ww -> open index [Assert]):
,ww
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wt -> open index in tab [Assert]):
,wt
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(2)
\<CR>
Do (,w,w -> open diary [Assert]):
,w,w
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,t -> open diary in tab [Assert]):
,w,t
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/diary/' . strftime('%Y-%m-%d') . '.md', expand('%')
\<CR>
:call AssertTab(2)
\<CR>
@ -102,28 +55,28 @@ Do (,ws -> list and select wiki [Assert]):
,ws
1
\<CR>
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wi -> open diary index [Assert]):
,wi
:AssertEqual 'test/resources/testmarkdown/diary/diary.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/diary/diary.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,y -> open yesterday [Assert]):
,w,y
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d', localtime() - 60*60*24) . '.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/diary/' . strftime('%Y-%m-%d', localtime() - 60*60*24) . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,w,m -> open tomorrow [Assert]):
,wm
:AssertEqual 'test/resources/testmarkdown/diary/' . strftime('%Y-%m-%d', localtime() + 60*60*24) . '.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/diary/' . strftime('%Y-%m-%d', localtime() + 60*60*24) . '.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
@ -144,13 +97,13 @@ Do (,wn -> Create new wiki [Assert]):
,wn
new_file1
\<CR>
:AssertEqual 'test/resources/testmarkdown/new_file1.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/new_file1.md', expand('%')
\<CR>
:call AssertTab(1)
\<CR>
Do (,wd -> Delete wiki yes [Assert]):
:edit 'test/resources/testmarkdown/file_new1.md'
:edit $HOME . '/testmarkdown/file_new1.md'
\<CR>
,wn
@ -163,11 +116,11 @@ Do (,wd -> Delete wiki yes [Assert]):
yes
\<CR>
:AssertEqual 'test/resources/testmarkdown/index.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/index.md', expand('%')
\<CR>
Do (,wd -> Delete wiki no [Assert]):
:edit 'test/resources/testmarkdown/file_new1.md'
:edit $HOME . '/testmarkdown/file_new1.md'
\<CR>
,wn
@ -180,7 +133,7 @@ Do (,wd -> Delete wiki no [Assert]):
no
\<CR>
:AssertEqual 'test/resources/testmarkdown/new_file2.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/new_file2.md', expand('%')
\<CR>
Do (,wn -> Rename wiki [Assert]):
@ -194,7 +147,7 @@ Do (,wn -> Rename wiki [Assert]):
new_file2
\<CR>
:AssertEqual 'test/resources/testmarkdown/new_file2.md', expand('%')
:AssertEqual $HOME . '/testmarkdown/new_file2.md', expand('%')
\<CR>
Given (Some headings):

View File

@ -4,8 +4,8 @@
# output function.
# Say Hi
echo -en "Starting $(basename $0) for VimWiki\n"
start_time=`date +%s`
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
@ -60,23 +60,16 @@ runVader() {
# Parse tests files to execute
if [[ -z $file_test ]]; then
ind="test/independent_runs/*.vader"
res="test/*"
else
read -ra TEST <<< "$file_test"
for i in "${TEST[@]}"; do
if [[ "$i" == "independent_runs/"*"*"* ]]; then
ind="$ind test/${i}"
elif [[ "$i" == *"*"* ]]; then
if [[ "$i" == *"*"* ]]; then
res="$res test/${i}"
elif [[ -f "$i" ]]; then
res="$res test/${i}"
elif [[ -f "${i}.vader" ]]; then
res="$res test/${i}.vader"
elif [[ -f "independent_runs/${i}" ]]; then
ind="$ind test/independent_runs/${i}"
elif [[ -f "independent_runs/${i}.vader" ]]; then
ind="$ind test/independent_runs/${i}.vader"
else
printf "WARNING: Test \"%s\" not found.\n", "$i"
fi
@ -94,10 +87,10 @@ runVader() {
home_save="$HOME"
# Create temporary root
mkdir -p $tmp_dir/vader_wiki
mkdir -p $tmp_dir/vader_wiki/home
mkdir -p $tmp_dir/vader_wiki/home/test
mkdir -p $tmp_dir/vader_wiki/testplugin
mkdir -p "$tmp_dir/vader_wiki"
mkdir -p "$tmp_dir/vader_wiki/home"
mkdir -p "$tmp_dir/vader_wiki/home/test"
mkdir -p "$tmp_dir/vader_wiki/testplugin"
# Set vars
export ROOT="$tmp_dir/vader_wiki/"
@ -127,57 +120,40 @@ runVader() {
# flags=(--rm -v "$PWD/../:/testplugin" -v "$PWD/../test:/home" -w /testplugin vimwiki)
echo -e "\nCopying resources to $ROOT"
# Copy testplugin
cp -rf $wiki_path/* $ROOT/testplugin/
cp -rf "$wiki_path/"* "$ROOT/testplugin/"
# Copy home
cp -rf $script_path/* $HOME/test/
cp -rf "$script_path/"* "$HOME/test/"
# Copy rtp.vim
cp -rf $script_path/resources/rtp_local.vim $ROOT/rtp.vim
cp -rf "$script_path/resources/rtp_local.vim" "$ROOT/rtp.vim"
# Copy vader <- internet
echo 'Cloning Vader (git, do not care the fatal)'
git clone --depth 10 https://github.com/junegunn/vader.vim /tmp/vader_wiki/vader 2>&1
fi
# Run batch of tests
# shellcheck disable=SC2086,SC2206
if [[ "$res" != "" ]]; then
if [[ "$v" == "local" ]]; then
pushd $tmp_dir/vader_wiki/testplugin
pushd "$tmp_dir/vader_wiki/testplugin" \
|| echo 'Warning pushd testplugin failed'
# Run the tests
echo -e "\nStarting Batch Vim/Vader <- $res"
"$vim" $vim_opt "+Vader! ${res}" 2>&1
ret=${PIPESTATUS[1]}; err=$(( $err + $ret ))
acmd=("$vim" $vim_opt \"+Vader! ${res}\" "2>&1")
echo -e "\nStarting Batch Vim/Vader:\n${acmd[*]}\n<- $res\n"
${acmd[*]}
ret=${PIPESTATUS[1]}; err=$(( err + ret ))
echo -e "\nReturned Batch Vim/Vader -> $ret"
popd
popd \
|| echo 'Warning popd also failed'
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
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 -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 -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"
acmd=(docker run -a stderr -e "VADER_OUTPUT_FILE=/dev/stderr"
"${flags[@]}" "$v" $vim_opt \"+Vader! ${res}\" "2>&1")
echo -e "\nStarting Batch Vim/Vader:\n${acmd[*]}\n<- $res\n"
${acmd[*]} | vader_filter | vader_color
ret=${PIPESTATUS[1]}; err=$(( err + ret ))
echo -e "\nReturned Batch Docker/Vim/Vader -> $ret"
fi
fi
@ -196,14 +172,16 @@ runVint() {
cmd="vint -s . && vint -s test/vimrc"
if echo "$vers" | grep "local" > /dev/null; then
echo -e "\nRunning Vint: $cmd : in $wiki_path"
pushd $wiki_path > /dev/null
pushd "$wiki_path" > /dev/null \
|| echo 'Warning pushd wiki_path failed'
$cmd
err=$(( $err | $? ))
popd > /dev/null
err=$(( err | $? ))
popd > /dev/null \
|| echo 'Warning popd also failed'
else
echo -e "\nStarting Docker container and running Vint: $cmd"
docker run -a stdout "${flags[@]}" bash -c "$cmd"
err=$(( $err | $? ))
err=$(( err | $? ))
fi
return $err
}
@ -287,10 +265,10 @@ vader_color() {
}
# path of the script, supposing no spaces
script_file="$(dirname $0)"
script_path="$( realpath $script_file )"
wiki_path="$( realpath $script_path/.. )"
tmp_dir=$(dirname $(mktemp -u))
script_file="$(dirname "$0")"
script_path="$( realpath "$script_file" )"
wiki_path="$( realpath "$script_path/.." )"
tmp_dir="$(dirname "$(mktemp -u)")"
# list of vim/nvim versions
vers="$(getVers)"
@ -358,20 +336,20 @@ case $type in
"vader" )
runVader ; err=$?
echo "Main Vader: returned $err"
o_error=$(( $err | $o_error ))
o_error=$(( err | o_error ))
;;
"vint" )
runVint ; err=$?
echo "Main Vint: returned $err"
o_error=$(( $err | $o_error ))
o_error=$(( err | o_error ))
;;
"all" )
runVint ; err=$?
echo "Main Vint: returned $err"
o_error=$(( $err | $o_error ))
o_error=$(( err | o_error ))
runVader ; err=$?
echo "Main Vader: returned $err"
o_error=$(( $err | $o_error ))
o_error=$(( err | o_error ))
;;
* )
echo "Error: invalid type - '$type'" 1>&2
@ -379,10 +357,10 @@ case $type in
esac
# Calcultate time
end_time=`date +%s`
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))
printf -v script_time '%dh:%dm:%ds' $((sec_time/3600)) $((sec_time%3600/60)) $((sec_time%60))
# Exit
echo -ne "Script $(basename $0), in $script_time, Returned -> $o_error\n\n"
echo -ne "Script $(basename "$0"), in $script_time, Returned -> $o_error\n\n"
exit $o_error

View File

@ -1,10 +1,6 @@
# Tag generation and navigation
# Note: The Generate must be in Execute
Execute (Copy Wiki's Resources):
Log "Start: Copy Resources"
call CopyResources()
Execute (Setup):
set sw=4
AssertEqual 4, &sw

View File

@ -200,7 +200,7 @@
" Write current file: helper to hide `set bt=`
function! WriteMe()
set buftype=
write %
write! %
endfunction
" Delete a file <- path <string>
@ -293,4 +293,8 @@
AssertEqual a:one, a:two
endfunction
" Copy Wiki's Resources
call CopyResources()
" vim: ft=vim:sw=2