2016-03-06 04:53:07 +01:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
2016-03-14 23:50:24 +01:00
|
|
|
DIR="${0:a:h}"
|
2016-03-06 04:53:07 +01:00
|
|
|
ROOT_DIR="$DIR/.."
|
|
|
|
TEST_DIR="$ROOT_DIR/test"
|
|
|
|
|
|
|
|
header() {
|
|
|
|
local message="$1"
|
|
|
|
|
|
|
|
cat <<-EOF
|
|
|
|
|
|
|
|
#====================================================================#
|
|
|
|
# $message
|
|
|
|
#====================================================================#
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2016-03-15 16:03:57 +01:00
|
|
|
# ZSH binary to use
|
|
|
|
local zsh_bin="zsh"
|
|
|
|
|
|
|
|
while getopts ":z:" opt; do
|
|
|
|
case $opt in
|
|
|
|
z)
|
|
|
|
zsh_bin="$OPTARG"
|
|
|
|
;;
|
|
|
|
\?)
|
|
|
|
echo "Invalid option: -$OPTARG" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
:)
|
|
|
|
echo "Option -$OPTARG requires an argument" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
shift $((OPTIND -1))
|
2016-03-06 04:53:07 +01:00
|
|
|
|
|
|
|
# Test suites to run
|
2016-03-15 16:03:57 +01:00
|
|
|
local -a tests
|
|
|
|
if [ $#@ -gt 0 ]; then
|
|
|
|
tests=($@)
|
|
|
|
else
|
|
|
|
tests=($TEST_DIR/**/*_test.zsh)
|
|
|
|
fi
|
|
|
|
|
|
|
|
local -i retval=0
|
2016-03-06 04:53:07 +01:00
|
|
|
|
|
|
|
for suite in $tests; do
|
2016-03-15 16:20:07 +01:00
|
|
|
header "${suite#"$ROOT_DIR/"}"
|
2016-03-15 16:03:57 +01:00
|
|
|
"$zsh_bin" -f "$suite" || retval=$?
|
2016-03-06 04:53:07 +01:00
|
|
|
done
|
|
|
|
|
2016-03-15 16:03:57 +01:00
|
|
|
exit $retval
|