-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests.sh
executable file
·79 lines (74 loc) · 2.39 KB
/
run-tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
fg_comment=$(tput setaf 8)
fg_preview=$(tput setaf 3)
fg_normal=$(tput sgr0)
fg_header=$(tput setaf 4)
interactive=0
args=$@
while [ $# -gt 0 ] ; do
case $1 in
-h|--help)
echo "${fg_preview}run-tests.sh [-i] [TESTFILE [TESTFILE...]]${fg_normal}"
echo
echo "${fg_header}DESCRIPTION:${fg_normal}"
echo " runs unittests (all by default)"
echo
echo "${fg_header}ARGUMENTS:${fg_normal}"
echo " -i --interactive"
echo " runs vader interactively (defaults to non-interactive)"
echo
echo "${fg_header}EXAMPLES:${fg_normal}"
echo " ${fg_comment}# run all tests, non-interactively${fg_normal}"
echo " ./run-tests.sh"
echo
echo " ${fg_comment}# run all tests, interactively${fg_normal}"
echo " ./run-tests.sh -i"
echo
echo " ${fg_comment}# run single testfile, non-interactively${fg_normal}"
echo " ./run-tests.sh tests/viml/test_error.vader"
echo
echo " ${fg_comment}# run multiple testfiles, non-interactively${fg_normal}"
echo " ./run-tests.sh \\"
echo " tests/viml/test_error.vader \\"
echo " tests/viml/test_graphql.vader"
echo
exit 0
;;
-i|--interactive)
interactive=1
args=( "${args[@]/$1}" )
shift
;;
*)
shift
;;
esac
done
if test -z "${args}" ; then
default_tests='tests/viml/*.vader'
else
default_tests=""
fi
test -d .test_deps || mkdir -p .test_deps
test -e .test_deps/vader.vim/.git || git clone https://github.com/junegunn/vader.vim .test_deps/vader.vim
test -e .test_deps/jellybeans.vim/.git || git clone https://github.com/nanotech/jellybeans.vim .test_deps/jellybeans.vim
vimrc=$(cat <<-END
filetype off
set rtp+=.test_deps/vader.vim
set rtp+=.test_deps/jellybeans.vim
set rtp+=.
filetype plugin indent on
syntax enable
colorscheme jellybeans
map <leader>q :q<CR>
END
)
if [[ "$interactive" == "1" ]] ; then
vadercmd='+Vader '
vadercmd+=" $default_tests"
vim -Nu <(echo "$vimrc") "$vadercmd ${args[@]}"
else
vadercmd='Vader! '
vadercmd+=" $default_tests"
vim -Nu <(echo "$vimrc") -c "$vadercmd ${args[@]}" > /dev/null
fi