Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mechatroner committed Jan 3, 2019
1 parent 0f879b9 commit 4aa49c3
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 1 deletion.
1 change: 0 additions & 1 deletion autoload/rainbow_csv.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ let s:system_python_interpreter = ''
let s:magic_chars = '^*$.~/[]\'

" FIXME move vim-specific tests into "test" directory. It should call test_all.sh from itself
" FIXME immediately show F7 hint after query execution

func! s:init_groups_from_links()
let link_groups = ['String', 'Comment', 'NONE', 'Special', 'Identifier', 'Type', 'Question', 'CursorLineNr', 'ModeMsg', 'Title']
Expand Down
File renamed without changes.
115 changes: 115 additions & 0 deletions test/test_vim_integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#!/usr/bin/env bash


cleanup_tmp_files() {
rm movies.tsv.py.rs 2> /dev/null
rm movies.tsv.js.rs 2> /dev/null
rm movies.tsv.system_py.py.rs 2> /dev/null
rm movies.tsv.system_py.js.rs 2> /dev/null
rm university_ranking.rs.tsv 2> /dev/null
rm vim_unit_tests.log 2> /dev/null
rm vim_debug.log 2> /dev/null
rm movies_small.tsv.csv 2> /dev/null
rm movies_small.tsv.csv.tsv 2> /dev/null
}


vim=vim
skip_rbql_tests="False"

while test ${#} -gt 0
do
if [ $1 == "--vim" ]; then
shift
vim=$1
shift
elif [ $1 == "--skip_rbql_tests" ]; then
shift
skip_rbql_tests="True"
else
echo "Error. Unknown parameter: $1" 1>&2
shift
exit 1
fi
done


if [ $skip_rbql_tests == "False" ]; then
echo "Starting RBQL unit tests"
cd ../rbql_core
./test_all.sh
cd ../test
echo "Finished RBQL unit tests"
else
echo "Skipping RBQL unit tests"
fi



echo "Starting vim integration tests"

cleanup_tmp_files

has_node="yes"

node_version=$( node --version 2> /dev/null )
rc=$?
if [ "$rc" != 0 ] || [ -z "$node_version" ] ; then
echo "WARNING! Node.js was not found. Skipping node vim tests" 1>&2
has_node="no"
fi

if [ "$has_node" == "yes" ] ; then
$vim -s unit_tests.vim -V0vim_debug.log -u test_vimrc
else
$vim -s unit_tests_py_only.vim -V0vim_debug.log -u test_vimrc
cp movies.tsv.py.rs movies.tsv.js.rs 2> /dev/null
cp movies.tsv.system_py.py.rs movies.tsv.system_py.js.rs 2> /dev/null
fi
errors=$( cat vim_debug.log | grep '^E[0-9][0-9]*' | wc -l )
total=$( cat vim_unit_tests.log | wc -l )
started=$( cat vim_unit_tests.log | grep 'Starting' | wc -l )
finished=$( cat vim_unit_tests.log | grep 'Finished' | wc -l )
fails=$( cat vim_unit_tests.log | grep 'FAIL' | wc -l )
if [ $total != 6 ] || [ $started != $finished ] || [ $fails != 0 ] ; then
echo "FAIL! Integration tests failed: see vim_unit_test.log" 1>&2
exit 1
fi

md5sum_movies_csv_canon="bb13547839020c33ba0da324fd0bb197"
md5sum_movies_tsv_canon="2a8016ac2cb05f52a1fd391a909112f5"

md5sum_test_1=($( md5sum movies.tsv.py.rs ))
md5sum_test_2=($( md5sum movies.tsv.js.rs ))
md5sum_test_3=($( md5sum movies.tsv.system_py.py.rs ))
md5sum_test_4=($( md5sum movies.tsv.system_py.js.rs ))
md5sum_update=($( md5sum university_ranking.rs.tsv ))
md5sum_movies_csv_test=($( md5sum movies_small.tsv.csv ))
md5sum_movies_tsv_test=($( md5sum movies_small.tsv.csv.tsv ))

md5sum_canonic=($( md5sum unit_tests/canonic_integration_1.tsv ))
sanity_len=$( printf "$md5sum_canonic" | wc -c )

if [ "$sanity_len" != 32 ] || [ "$md5sum_test_1" != $md5sum_canonic ] || [ "$md5sum_test_2" != $md5sum_canonic ] || [ "$md5sum_test_3" != $md5sum_canonic ] || [ "$md5sum_test_4" != $md5sum_canonic ] ; then
echo "FAIL! Integration tests failed: md5sums" 1>&2
exit 1
fi

if [ "$md5sum_movies_csv_canon" != "$md5sum_movies_csv_test" ] || [ "$md5sum_movies_tsv_canon" != "$md5sum_movies_tsv_test" ] ; then
echo "FAIL! Integration tests failed: md5sums for movies_small" 1>&2
exit 1
fi

if [ "$md5sum_update" != "fcc44cf2080ec88b56062472bbd89c3b" ] ; then
echo "FAIL! Update integration tests failed: md5sums" 1>&2
exit 1
fi

if [ $errors != 0 ] || [ ! -e vim_debug.log ] ; then
echo "Warning: some errors were detected during vim integration testing, see vim_debug.log" 1>&2
exit 1
fi

cleanup_tmp_files

echo "Finished vim integration tests"

0 comments on commit 4aa49c3

Please sign in to comment.