Repository navigation
Expand file tree
/
Copy pathtest-runner.bash
More file actions
99 lines (72 loc) · 1.96 KB
/
Copy pathtest-runner.bash
File metadata and controls
99 lines (72 loc) · 1.96 KB
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
if ! declare -f import:use &>/dev/null; then
echo "test-runner must be imported using import.bash" >&2
exit 2
fi
import:use "github.com/reconquest/opts.bash"
_test_runner_local_setup=tests/setup.sh
_test_runner_local_teardown=tests/teardown.sh
_test_runner_testcases_dir=tests/testcases
_test_runner_custom_opts=()
test-runner:handle-custom-opt() {
:
}
test-runner:handle-args() {
:
}
test-runner:progress() {
cat >/dev/null
}
test-runner:set-custom-opts() {
_test_runner_custom_opts=${@}
}
test-runner:set-testcases-dir() {
_test_runner_testcases_dir=$1
}
test-runner:set-local-setup() {
_test_runner_local_setup=$1
}
test-runner:set-local-teardown() {
_test_runner_local_teardown=$1
}
test-runner:run() {
local -A opts
local -a args
opts:parse opts args \
-h --help -v -A -O ${_test_runner_custom_opts[@]:-} -- "${@}"
for custom_opt in ${_test_runner_custom_opts[@]:-}; do
local custom_opt_name="${custom_opt//:}"
if [ "${opts[$custom_opt_name]:-}" ]; then
test-runner:handle-custom-opt "$custom_opt_name" \
"${opts[$custom_opt_name]}"
fi
done
local run_flags=()
if [ "${opts[-h]:-}" -o "${opts[--help]:-}" ]; then
run_flags=(-v)
elif [ "${opts[-O]:-}" ]; then
if [ ${#args[@]} -gt 1 ]; then
run_flags=(-O "${args[1]}")
unset args[1]
else
run_flags=(-O)
fi
else
run_flags=(-A)
fi
test-runner:handle-args "${args[@]:-}"
(
import:use github.com/reconquest/tests.sh
tests:progress() {
test-runner:progress "${@}"
}
if [ "${opts[-v]:-}" ]; then
tests:set-verbose "${opts[-v]}"
fi
tests:main \
-a \
-d "$_test_runner_testcases_dir" \
-s "$_test_runner_local_setup" \
-t "$_test_runner_local_teardown" \
"${run_flags[@]}"
)
}