zsh-autosuggestions/script/test_runner.zsh

55 lines
813 B
Bash
Raw Permalink Normal View History

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
}
# 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
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/"}"
"$zsh_bin" -f "$suite" || retval=$?
2016-03-06 04:53:07 +01:00
done
exit $retval