diff --git a/Makefile b/Makefile index 6a7679e..bd649f6 100644 --- a/Makefile +++ b/Makefile @@ -56,4 +56,4 @@ clean: .PHONY: test test: all $(TEST_PREREQS) - script/test_runner.zsh + script/test_runner.zsh $(TESTS) diff --git a/script/test_runner.zsh b/script/test_runner.zsh index 5ab06d6..848cb94 100755 --- a/script/test_runner.zsh +++ b/script/test_runner.zsh @@ -15,15 +15,40 @@ header() { EOF } -local -a tests +# ZSH binary to use +local zsh_bin="zsh" -# Test suites to run -tests=($TEST_DIR/**/*_test.zsh) - -local retval=0 -for suite in $tests; do - header "${suite#"$TEST_DIR"}" - zsh -f "$suite" || retval=$? +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 -exit retval +shift $((OPTIND -1)) + +# Test suites to run +local -a tests +if [ $#@ -gt 0 ]; then + tests=($@) +else + tests=($TEST_DIR/**/*_test.zsh) +fi + +local -i retval=0 + +for suite in $tests; do + header "${suite#"$TEST_DIR"}" + "$zsh_bin" -f "$suite" || retval=$? +done + +exit $retval