-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-tests.sh
executable file
·55 lines (46 loc) · 1.21 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
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -uo pipefail
unset BACH_ASSERT_DIFF BACH_ASSERT_DIFF_OPTS
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin
bash_bin="$BASH"
OS_NAME="$(uname)"
if [[ -e /etc/os-release ]]; then
source /etc/os-release
OS_NAME="${OS_NAME}-${ID}-${VERSION_ID}"
fi
case "$OS_NAME" in
Darwin)
if ! brew list --full-name --versions bash &>/dev/null; then
brew install bash
fi
if [[ "$BASH" == /bin/bash ]]; then
bash_bin="$(brew --prefix)"/bin/bash
fi
;;
Linux-alpine-*)
apk update
apk add coreutils diffutils perl-utils
;;
esac
echo "$bash_bin"
"$bash_bin" --version
function out() {
printf "\n\e[1;37;497;m%s\e[0;m\n" "$@"
} >&2
function err() {
printf "\n\e[1;37;41;m%s\e[0;m\n\n" "$@"
} >&2
retval=0
cd "$(dirname "${BASH_SOURCE}")"
for file in examples/test* lib/bach/examples/learn* lib/bach/tests/*.test.sh; do
out "Running $file"
if grep -E "^[[:blank:]]*BACH_TESTS=.+" "$file"; then
err "Found defination of BACH_TESTS in $file"
retval=1
fi
"$bash_bin" -euo pipefail "$file" || retval=1
done
if [[ "$retval" -ne 0 ]]; then
err "Test failed!"
fi
exit "$retval"