-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_tests
executable file
·118 lines (87 loc) · 1.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
#!/bin/bash
LOGFILE=testing.log
echo logging to \""$LOGFILE"\"
cat > $LOGFILE <<EOD
-------------------------------------------
Testing MRtrix3 installation
-------------------------------------------
EOD
echo -n "fetching test data... "
git submodule update --init >> $LOGFILE 2>&1
if [ $? != 0 ]; then
echo ERROR!
exit 1
else
echo OK
fi
echo -n "building testing commands... "
cat >> $LOGFILE <<EOD
-------------------------------------------
## building test commands...
EOD
(
cd testing
../build
) >> $LOGFILE 2>&1
if [ $? != 0 ]; then
echo ERROR!
exit 1
else
echo OK
fi
# generate list of tests to run:
if [ $# == 0 ]; then
for n in testing/tests/*; do
tests="$tests $(basename $n)"
done
else
tests="$@"
fi
a_script_has_failed=false
cat >> $LOGFILE <<EOD
PATH is set to $PATH
EOD
for script in $tests; do
cat >> $LOGFILE <<EOD
-------------------------------------------
## running "${script}"...
EOD
echo -n 'running "'${script}'"... '
rm -f testing/data/tmp*
((ntests=0))
((success=0))
while IFS='' read -r cmd || [[ -n "$cmd" ]]; do
echo -n '# command: '$cmd >> $LOGFILE
(
export PATH="$(pwd)/testing/release/bin:$(pwd)/release/bin:$PATH";
cd testing/data/
eval $cmd
) > .__tmp.log 2>&1
if [[ $? -ne 0 ]]; then
echo " [ ERROR ]" >> $LOGFILE
else
echo " [ ok ]" >> $LOGFILE
((success++));
fi
cat .__tmp.log >> $LOGFILE
echo "" >> $LOGFILE
((ntests++))
done < testing/tests/$script
echo -n $success of $ntests passed
if [[ $success -lt $ntests ]]; then
echo " <-------- ERROR"
a_script_has_failed=true
cat >> $LOGFILE <<EOD
## ERROR: $(($ntests-$success)) tests failed for "${script}"
EOD
else
echo ""
cat >> $LOGFILE <<EOD
## $ntests tests completed OK for "${script}"
EOD
fi
done
if [ ${a_script_has_failed} = true ];
then
exit 1
fi