-
Notifications
You must be signed in to change notification settings - Fork 4
/
vutest.sh
executable file
·73 lines (61 loc) · 1.56 KB
/
vutest.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
#!/bin/sh
# (c) 2012, Dane Summers <[email protected]>
#
# This work is licensed under the Creative Commons Attribution 3.0 Unported
# License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by/3.0/.
set -u
# don't want to fail on a test failure, we'll handle it in the script and pass it on.
# set -e
help() {
echo "vutest.sh [-v] <script.vim> [testpattern]"
echo ""
echo "Run vimUnit tests and return results to the command line. If testpattern is supplied"
echo "then only tests matching the testpattern will run, otherwise all tests are run."
echo ""
echo "Options:"
echo " -v Verbose. If set, then messages passed to MsgSink will be displayed when tests fail."
echo " -f <output> Save output to a specific file rather than STDOUT."
echo " -e <VIM> Specific path to the VIM program."
echo ""
echo "Example:"
echo " vutest.sh ~/.vim/bundle/vimunit/plugin/vim_unit.vim"
exit 1
}
VERBOSE=0
VIM='vim'
FILE=`mktemp log.txt-XXXX`
TOSTDOUT=1
while getopts "vf:e:" opt; do
case $opt in
v )
VERBOSE=1
;;
f )
FILE=$OPTARG
TOSTDOUT=0
;;
e )
VIM=$OPTARG
;;
\?)
help
;;
esac
done
if [[ $# -lt 1 ]]; then
help
fi
shift $((OPTIND-1))
if [[ $# -eq 1 ]]; then
$VIM -nc ":so % | let g:vimUnitVerbosity=$VERBOSE | call VURunAllTests('.*',1,'$FILE')" $1
elif [[ $# -eq 2 ]]; then
$VIM -nc ":so % | let g:vimUnitVerbosity=$VERBOSE | call VURunAllTests('$2',1,'$FILE')" $1
else
help
fi
returncode=$?
if [[ $TOSTDOUT -eq 1 ]]; then
cat $FILE
fi
exit $returncode