summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-12-17 17:11:30 -0500
committerTavian Barnes <tavianator@tavianator.com>2018-12-17 17:13:27 -0500
commit6b2494424fc8e6c49d6816294b5df5b1fe7f4c74 (patch)
tree7dcae589d2ce98b7c2f46cf10cf3392f1fc5deb1
parente95ec269efdfbd97b5d0ee85dda38e7bae498181 (diff)
downloadbfs-6b2494424fc8e6c49d6816294b5df5b1fe7f4c74.tar.xz
tests.sh: Add a --help with usage information
-rwxr-xr-xtests.sh37
1 files changed, 36 insertions, 1 deletions
diff --git a/tests.sh b/tests.sh
index 35f0224..4afe094 100755
--- a/tests.sh
+++ b/tests.sh
@@ -606,6 +606,36 @@ bfs_tests=(
test_deep_strict
)
+function usage() {
+ local pad=$(printf "%*s" ${#0} "")
+ cat <<EOF
+Usage: $0 [--bfs=path/to/bfs] [--posix|--bsd|--gnu|--all]
+ $pad [--noclean] [--update] [--verbose] [--help]
+ $pad [test_* [test_* ...]]
+
+ --bfs=path/to/bfs
+ Set the path to the bfs executable to test (default: ./bfs)
+
+ --posix|--bsd|--gnu|--all
+ Restrict the set of test cases to run
+
+ --noclean
+ Keep the test directories around after the run
+
+ --update
+ Update the expected outputs for the test cases
+
+ --verbose
+ Log the commands that get executed
+
+ --help
+ This message
+
+ test_*
+ Select individual test cases to run
+EOF
+}
+
BSD=yes
GNU=yes
ALL=yes
@@ -650,12 +680,17 @@ for arg; do
--verbose)
VERBOSE=yes
;;
+ --help)
+ usage
+ exit 0
+ ;;
test_*)
EXPLICIT=yes
enable_tests "$arg"
;;
*)
- echo "Unrecognized option '$arg'." >&2
+ printf "Unrecognized option '%s'.\n\n" "$arg" >&2
+ usage >&2
exit 1
;;
esac