forked from cobbler/cobbler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-tests
executable file
·68 lines (59 loc) · 1.36 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
#!/usr/bin/env bash
# Run the system tests
topdir=$(realpath $(dirname ${0})/..)
if [ ${#} -ge 1 ]; then
patterns=${@}
else
patterns=(basic-* import-*)
fi
list_selected_tests() {
local expression=()
for pattern in ${patterns[@]}; do
expression+=('-e' "^${pattern}")
done
find ${topdir}/tests ! -type d -executable | sed 's|^.*/||' | \
grep -vE -e '^\.' -e '*-@$' | grep "${expression[@]}" | sort
}
failed_tests=()
export SYSTESTS_ROOT=${topdir}
export SYSTESTS_PRELUDE=${topdir}/prelude
export SYSTESTS_TMP=${topdir}/workspace
rm -rf ${SYSTESTS_TMP}
echo
echo "Patterns:"
for pattern in ${patterns[@]}; do
echo " ${pattern}"
done
echo
echo "Running tests:"
for test in $(list_selected_tests); do
test_dir=${SYSTESTS_TMP}/${test}
printf ' %s... ' ${test}
mkdir -p ${test_dir}
env TEST_NAME=${test} ${topdir}/tests/${test} >${test_dir}/_output 2>&1
if [ ${?} -eq 0 ]; then
echo ok
else
echo fail
failed_tests+=(${test})
touch ${test_dir}/_failed
fi
done
if [ ${#failed_tests[@]} != 0 ]; then
echo
echo "The following tests have failed:"
for test in ${failed_tests[@]}; do
echo " ${test}"
done
echo
echo "The outputs of the failed tests below."
echo "The last command is the one that failed."
echo
for test in ${failed_tests[@]}; do
echo "==> ${SYSTESTS_TMP}/${test}/output <=="
echo
cat ${SYSTESTS_TMP}/${test}/_output
echo
done
exit 1
fi