forked from inspircd/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
executable file
·47 lines (39 loc) · 1.17 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
#!/bin/bash
export INSP_VERSION
clean_up() {
local ret_val="$?"
# Clean up any remaining containers (e.g., due to fast-failing test)
local inspircd_containers="$(docker ps -q -a -f "ancestor=inspircd:testing")"
if [[ -n "${inspircd_containers}" ]]; then
docker rm -fv ${inspircd_containers}
fi
# Exit with ultimate exit code
exit "${ret_val}"
}
trap clean_up EXIT
# Make sure test-tracking file exists
touch ok_tests.txt
pad=$(printf '.%.0s' {1..100})
for test_file in tests/*.sh; do
printf "%.35s " "${test_file} ${pad}"
# Check if test already passed.
grep -w -q "$(sha1sum "${test_file}")" ok_tests.txt \
&& { printf "0 ( OK )\n"; continue; } \
|| true
# Run test, capturing all output to log variable
test_log=$(sh "${test_file}" 2>&1)
[[ $? -eq 0 ]] \
&& {
echo "0 ( OK )"
sha1sum "${test_file}" >> ok_tests.txt
} \
|| {
ret=$?
echo "${ret} (FAIL)"
# Print full output of test script
echo "${test_log}"
exit ${ret}
}
done
# Remove test-tracking cache on successful tests.
rm ok_tests.txt