-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathrun-tests.sh
executable file
·74 lines (66 loc) · 1.7 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
set -ue
[ -z "${DEBUG:-}" ] || set -x
unset BACH_ASSERT_DIFF BACH_ASSERT_DIFF_OPTS
OS_NAME="$(uname)"
if [ -e /etc/os-release ]; then
. /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 2>&1; then
brew install bash
fi
bash_bin="$(brew --prefix)"/bin/bash
;;
FreeBSD*)
export PATH="/usr/local/sbin:$PATH"
export ASSUME_ALWAYS_YES=yes
pkg_install_pkgs="pkg -vv; pkg update -f; pkg install -y bash base64"
if ! hash bash || ! hash xxd; then
if [ "$(id -u)" -gt 0 ] && hash sudo; then
sudo /bin/sh -c "$pkg_install_pkgs"
else
/bin/sh -c "$pkg_install_pkgs"
fi
fi
;;
Linux-alpine-*)
apk update
hash bash >/dev/null 2>&1 || apk add bash
apk add coreutils diffutils
;;
esac
if [ -z "${bash_bin:-}" ]; then
bash_bin="$(which bash)"
fi
uname -a
echo "Bash: $bash_bin"
test -n "$bash_bin"
"$bash_bin" --version
err() {
echo "$*" >&2
}
set +e
retval=0
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin
cd "$(dirname "$0")"
for file in tests/*.test.sh examples/learn*; do
echo "Running $file"
if grep -E "^[[:blank:]]*BACH_TESTS=.+" "$file"; then
err "Found defination of BACH_TESTS in $file"
retval=1
fi
if [ "${file##*/failed-}" != "${file}" ]; then
! "$bash_bin" -euo pipefail "$file"
else
"$bash_bin" -euo pipefail "$file"
fi || retval=1
done
if [ "$retval" -ne 0 ]; then
err ""
err ":----------:"
err "Test failed!"
fi
exit "$retval"