-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·59 lines (47 loc) · 997 Bytes
/
test.sh
File metadata and controls
executable file
·59 lines (47 loc) · 997 Bytes
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
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# shellcheck disable=SC1091
source "$SCRIPT_DIR/tests/common.sh"
# shellcheck disable=SC1090
for f in "$SCRIPT_DIR"/tests/test_*.sh; do
source "$f"
done
if [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then
usage
exit 0
fi
TESTS_TO_RUN=("${@}")
if [ ${#TESTS_TO_RUN[@]} -eq 0 ]; then
TESTS_TO_RUN=("${ALL_TESTS[@]}")
fi
for t in "${TESTS_TO_RUN[@]}"; do
if ! declare -f "$t" >/dev/null 2>&1; then
echo "unknown test: $t"
echo ""
usage
exit 1
fi
done
trap cleanup EXIT
setup
echo ""
echo "=== running ${#TESTS_TO_RUN[@]} test(s) ==="
echo ""
FAILED=0
PASSED=0
for t in "${TESTS_TO_RUN[@]}"; do
echo "--- $t ---"
test_setup
if $t; then
PASSED=$((PASSED + 1))
else
FAILED=$((FAILED + 1))
fi
test_teardown
done
echo ""
echo "=== results: $PASSED passed, $FAILED failed ==="
if [ "$FAILED" -gt 0 ]; then
exit 1
fi