forked from aaSSfxxx/r2-regressions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
executable file
·107 lines (95 loc) · 2.41 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
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
#!/bin/sh
#
# Copyright (C) 2011-2015 pancake <[email protected]>
# Copyright (C) 2011-2012 Edd Barrett <[email protected]>
# Copyright (C) 2012 Simon Ruderich <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cd `dirname $0` 2>/dev/null
r2 -v
if [ $? != 0 ]; then
echo "Cannot find r2"
exit 1
fi
# Statistics.
TESTS_TOTAL=0
TESTS_SUCCESS=0
TESTS_FAILED=0
TESTS_BROKEN=0
TESTS_FIXED=0
TESTS_FATAL=0
# Let tests.sh know the complete test suite is run, enables statistics.
R2_SOURCED=1
control_c() {
echo
exit 1
}
trap control_c 2
. ./tests.sh
r2 > /dev/null
if [ $? != 0 ]; then
echo "Cannot find r2"
exit 1
fi
R=$PWD
# Run all tests.
T="t"; [ -n "$1" ] && T="$1"
if [ -f "$T" -a -x "$T" ]; then
BDIR=`dirname $T`
FILE=`basename $T`
cd $BDIR
. ./$FILE
else
cd $T || die "t/ doesn't exist"
for file in * ; do
[ "$file" = '*' ] && break
if [ -d "$file" ]; then
cd $file
for file2 in *; do
[ "$file2" = '*' ] && break
TEST_NAME=$(echo "${file2}" | sed 's/.sh$//')
NAME=`basename $file2`
TEST_NAME=$file
if [ -f "${file2}" ]; then
. ./${file2}
fi
done
cd ..
elif [ ! -x "$file" ]; then # Only run files marked as executable.
print_found_nonexec "$file"
else
NAME=`basename $file`
TEST_NAME=$NAME
. ./${file}
fi
done
fi
print_report
# Save statistics
cd $R
V=`r2 -v 2>/dev/null| grep ^rada| awk '{print $5}'`
touch stats.csv
grep -v "^$V" stats.csv > .stats.csv
echo "$V,${TESTS_SUCCESS},${TESTS_FIXED},${TESTS_BROKEN},${TESTS_FAILED},${TESTS_FATAL},${FAILED}" >> .stats.csv
sort .stats.csv > stats.csv
rm -f .stats.csv
# Exit codes, as documented in README.md
if [ "${TESTS_FATAL}" -gt 0 ]; then
echo "ESSENTIAL TEST HAS FAILED"
exit 1
elif [ "${TESTS_FAILED}" -gt 0 ]; then
exit 2
else
exit 0
fi