forked from otiai10/cwl.go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xtest.sh
executable file
·57 lines (51 loc) · 1.24 KB
/
xtest.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
#!/bin/bash
LIMIT_FOR_EACH_CASE=100
count_for_case=0
total=0
report=()
function exec_test() {
total=`expr ${total} + 1`
TESTCASE=${1}
count_for_case=`expr ${count_for_case} + 1`
if go test ./tests -run ${TESTCASE} ; then
echo "--- OK ${count_for_case}: ${TESTCASE}"
report+=("${count_for_case} ${TESTCASE}")
count_for_case=0
else
if [ ${count_for_case} -gt ${LIMIT_FOR_EACH_CASE} ]; then
echo ">> FAILED: TIMEOUT: ${count_for_case} times for ${TESTCASE} <<"
exit 1
fi
echo "--- TRY AGAIN: ${count_for_case}: ${TESTCASE}"
exec_test ${TESTCASE}
fi
}
function gather_testcases() {
targets=()
if [ -n "${1}" ]; then
list=`ls ./tests/*${1}*_test.go`
else
list=`ls ./tests/*_test.go`
fi
for filename in ${list} ; do
targets+=(`echo ${filename} | sed -e s/\.\\\/tests\\\/// | sed -e s/_test\.go//`)
done
echo ${targets[@]}
}
function final_report() {
IFS=''
echo "[COMPLETED]"
for r in ${report[@]} ; do
echo ${r}
done
echo "-------------------------"
echo "${total} TOTAL"
}
function __main__() {
testcases=`gather_testcases ${1}`
for t in ${testcases[@]} ; do
exec_test ${t}
done
final_report
}
__main__ $@