-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_integration_tests.sh
executable file
·190 lines (156 loc) · 4.36 KB
/
run_integration_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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/bash
git submodule update --init --recursive
if [ -z "$1" ] ; then
printf "Please supply the full path to rb as first argument.\n\n"
printf "Examples:\n"
printf ' ./run_integration_tests.sh "$(readlink -f ../projects/cmake/rb)"\n'
printf ' ./run_integration_tests.sh "$PWD/../projects/cmake/rb"\n'
printf ' ./run_integration_tests.sh -mpi true "$PWD/../projects/cmake/rb"\n'
# printf ' ./run_integration_tests.sh mpirun -np 4 "$(readlink -f ../projects/cmake/rb)"\n'
exit 101
fi
mpi="false"
# parse command line arguments
while echo $1 | grep ^- > /dev/null; do
# intercept help while parsing "-key value" pairs
if [ "$1" = "--help" ] || [ "$1" = "-h" ]
then
echo '
Command line options are:
-h : print this help and exit.
'
exit
fi
# parse pairs
eval $( echo $1 | sed 's/-//g' | tr -d '\012')=$2
shift
shift
done
if [ $mpi = "true" ]; then
# rb_exec="mpirun --oversubscribe -np 4 $@"
# rb_exec="mpirun -np 4 $@"
rb_exec="$@"
else
rb_exec="$@"
fi
export rb_exec
if ! ${rb_exec} --help > /dev/null 2>&1 ; then
echo "RevBayes command '${rb_exec}' seems not to work!\n"
exit 102
fi
tests=()
status=()
for t in revbayes.github.io/tutorials/*/test.sh; do
testname=`echo $t | cut -d '/' -f 2-3`
dirname=`echo $t | cut -d '/' -f 1-3`
cd $dirname
tests+=($testname)
printf "\n\n#### Running test: $testname\n\n"
sh test.sh
res="$?"
if [ $res = 1 ]; then
res="error: $f"
break
elif [ $res = 139 ]; then
res="segfault: $f"
break
elif [ $res != 0 ]; then
res="error $res: $f"
break
fi
status+=("$res")
cd -
done
for t in test_*; do
testname=`echo $t | cut -d _ -f 2-`
if [ -d $t ]; then
tests+=($testname)
else
continue
fi
printf "\n\n#### Running test: $testname\n\n"
cd $t
rm -rf output data
ln -s ../data data
res=0
# run the test scripts
for f in scripts/*; do
${rb_exec} -b $f # print output so we can see any error messages
res="$?"
if [ $res = 1 ]; then
res="error: $f"
break
elif [ $res = 139 ]; then
res="segfault: $f"
break
elif [ $res != 0 ]; then
res="error $res: $f"
break
fi
done
# store the exit status
status+=("$res")
rm data
cd ..
done
printf "\n\n#### Checking output from tests... \n"
xfailed=0
failed=0
pass=0
i=0
while [ $i -lt ${#tests[@]} ]; do
t=${tests[$i]}
if [ -d test_$t ]; then
cd test_$t
# check if output matches expected output
errs=()
exp_out_dir="output_expected"
# Sebastian: For now we only use single cores until we fix Travis mpirun
# if [ "${mpi}" = "true" ]; then
# if [ -d "output_expected_mpi" ]; then
# exp_out_dir="output_expected_mpi"
# fi
# fi
if [ "$windows" = "true" ]; then
find output -type f -exec dos2unix {} \;
find output -type f -exec sed -i 's/e-00/e-0/g' {} \;
find output -type f -exec sed -i 's/e+00/e+0/g' {} \;
fi
for f in $(ls ${exp_out_dir}); do
if [ ! -e output/$f ]; then
errs+=("missing: $f")
elif ! diff output/$f ${exp_out_dir}/$f > /dev/null; then
errs+=("mismatch: $f")
fi
done
cd ..
fi
# check if a script exited with an error
if [ "${status[$i]}" != 0 ]; then
errs=("${status[$i]}")
fi
# failure if we have an error message
if [ ${#errs[@]} -gt 0 ]; then
if [ -f XFAIL ] ; then
((xfailed++))
printf ">>>> Test failed: $t (expected)\n"
else
((failed++))
printf ">>>> Test failed: $t\n"
fi
for errmsg in "${errs[@]}"; do
printf "\t$errmsg\n"
done
else
((pass++))
printf "#### Test passed: $t\n"
fi
((i++))
done
if [ $failed -gt 0 ]; then
printf "\n\n#### Warning! unexpected failures: $failed expected failures: $xfailed total tests: $i\n\n"
exit 113
else
printf "\n\n#### Success! unexpected failures: $failed expected failures: $xfailed total tests: $i\n\n"
printf "\n\n#### All tests passed.\n\n"
fi