blob: 73a82a352b2cb384ef068168599daf18dad65dc7 (
plain) (
blame)
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
|
#!/bin/bash
cd "$(dirname "$0")"
TESTS=(test-*.sh)
PARALLEL=${PARALLEL:-1}
if [ ${#TESTS[@]} -eq 0 ]; then
echo "No tests found"
exit 1
fi
run_test() {
local test=$1
local output
if output=$(bash "$test" 2>&1); then
echo "✓ $test"
return 0
else
echo "✗ $test"
echo "$output" | sed 's/^/ /'
return 1
fi
}
export -f run_test
if [ "$PARALLEL" = "1" ]; then
echo "Running ${#TESTS[@]} tests in parallel..."
echo
failed=0
passed=0
for test in "${TESTS[@]}"; do
run_test "$test" &
done
for job in $(jobs -p); do
if wait $job; then
((passed++))
else
((failed++))
fi
done
echo
echo "Results: $passed passed, $failed failed"
if [ $failed -gt 0 ]; then
exit 1
fi
else
echo "Running ${#TESTS[@]} tests sequentially..."
echo
failed=0
passed=0
for test in "${TESTS[@]}"; do
if run_test "$test"; then
((passed++))
else
((failed++))
fi
echo
done
echo "Results: $passed passed, $failed failed"
if [ $failed -gt 0 ]; then
exit 1
fi
fi
|