forked from liquidprompt/liquidprompt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.sh
executable file
·43 lines (33 loc) · 898 Bytes
/
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
#!/bin/bash
if [[ -n ${1+x} ]]; then
shells=("$@")
else
shells=(bash zsh)
fi
cd "${0%/*}/tests"
if [ ! -r shunit2 ]; then
curl https://raw.githubusercontent.com/kward/shunit2/v2.1.8/shunit2 -O
fi
typeset -a testing_shells
for shell in "${shells[@]}"; do
if command -v "$shell" >/dev/null; then
testing_shells+=("$shell")
printf 'shell "%s": version "%s"\n' "$shell" "$("$shell" --version)"
else
printf "Cannot find shell '%s', skipping tests\n" "$shell" >&2
fi
done
typeset -i fail=0
typeset -a errors
for test_file in ./test_*.sh; do
for shell in "${testing_shells[@]}"; do
printf "\nRunning shell '%s' with test '%s'\n" "$shell" "$test_file"
"$shell" "$test_file" || {
fail+=1
errors+=("Failed running test '${test_file}' with shell '${shell}'")
}
done
done
printf '%s\n' "${errors[@]}"
exit "$fail"
# vim: ft=sh et sts=2 sw=2 tw=120