forked from puremourning/vimspector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests
executable file
·136 lines (113 loc) · 2.89 KB
/
run_tests
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env bash
if [ "$1" == "--help" ]; then
echo "$(basename $0) [--basedir <basedir>] [--install] <optional list of tests in form file:func>"
echo ""
echo " --basedir <basedir> path to runtime directory like the optino to install_gadget.py"
echo " --install run install_gadget.py, useful with --basedir"
echo "e.g.: "
echo " - run all tests: $0"
echo " - run specific tests script: $0 signature_help.test.vim"
echo " - run specific tests fun: $0 signature_help.test.vim:Test_signatures_TopLine\(\)"
echo " - run all tests in a clean env: $0 --basedir \$(mktemp -d) --install"
exit 0
fi
BASEDIR=$(dirname $0)
INSTALL=0
RUN_VIM="vim -N --clean --not-a-term"
RUN_TEST="${RUN_VIM} -S lib/run_test.vim"
BASEDIR_CMD='py3 pass'
while [ -n "$1" ]; do
case "$1" in
"--basedir")
BASEDIR=$2
if [[ ! $BASEDIR = /* ]]; then
# Relative
BASEDIR=$(pwd)/${BASEDIR}
fi
BASEDIR_CMD="let g:vimspector_base_dir='${BASEDIR}'"
shift
shift
;;
"--install")
INSTALL=1
shift
;;
"--")
shift
break
;;
*)
break
;;
esac
done
if [ $INSTALL = 1 ]; then
python3 $(dirname $0)/install_gadget.py --basedir ${BASEDIR} --all
fi
if [ -z "$VIMSPECTOR_MIMODE" ]; then
if which lldb >/dev/null 2>&1; then
export VIMSPECTOR_MIMODE=lldb
elif which gdb >/dev/null 2>&1; then
export VIMSPECTOR_MIMODE=gdb
else
echo "Couldn't guess VIMSPECTOR_MIMODE. Need lldb or gdb in path"
exit 1
fi
fi
echo "Testing with:"
echo " * VIMSPECTOR_MIMODE=$VIMSPECTOR_MIMODE"
echo " * RUN_VIM=$RUN_VIM"
echo " * RUN_TEST=$RUN_TEST"
echo " * BASEDIR_CMD=$BASEDIR_CMD"
echo "%SETUP - Building test programs..."
set -e
pushd tests/testdata/cpp/simple
make clean simple
popd
set +e
echo "%DONE - built test programs"
# Start
pushd $(dirname $0)/tests > /dev/null
echo "Running Vimspector Vim tests"
RESULT=0
TESTS="$@"
if [ -z "$TESTS" ]; then
TESTS=*.test.vim
fi
for t in ${TESTS}; do
echo ""
echo "%RUN: $t"
# split on : into fileName and testName
IFS=: read -s t T <<< "$t"
TESTLOGDIR=${BASEDIR}/tests/logs/$t
if ${RUN_TEST} --cmd "${BASEDIR_CMD}" \
--cmd 'au SwapExists * let v:swapchoice = "e"' $t $T \
&& [ -f $t.res ]; then
echo "%PASS: $t PASSED"
else
echo "%FAIL: $t FAILED - see $TESTLOGDIR"
RESULT=1
fi
rm -rf $TESTLOGDIR
mkdir -p $TESTLOGDIR
${RUN_VIM} --version > ${TESTLOGDIR}/vimversion
for l in messages debuglog test.log *.testlog; do
# In CI we can't view the output files, so we just have to cat them
if [ -f $l ]; then
if [ "$VIMSPECTOR_TEST_STDOUT" ]; then
echo ""
echo ""
echo "*** START: $l ***"
cat $l
echo "*** END: $l ***"
fi
mv $l $TESTLOGDIR
fi
done
rm -f $t.res
done
echo "Done running tests"
popd > /dev/null
echo ""
echo "All done."
exit $RESULT