Run a single named check with --only #28

Open
kami wants to merge 4 commits from orchestra/06G4W63545T3RV8SSKGKN11B3G into master
Showing only changes of commit 1f07b89c2c - Show all commits
+29 -1
View File
@@ -10,6 +10,14 @@ selftest_present test_healthcheck_present readme_present
no_crlf_line_endings no_tabs_in_scripts
shebang_is_bash usage_text_mentions_every_flag"
# check_exists <name>: true when <name> is one of the CHECKS names.
check_exists() {
case " $(printf '%s ' $CHECKS) " in
*" $1 "*) return 0 ;;
esac
return 1
}
# name=ok / name=fail pairs, in run order.
RESULTS=
FAILED=0
@@ -103,8 +111,16 @@ main() {
local timing=
local strict=
local unknown=
local only=
local expect_only=
for arg in "$@"; do
if [ "$arg" = --help ]; then
if [ -n "$expect_only" ]; then
only=$arg
expect_only=
continue
elif [ "$arg" = --only ]; then
expect_only=1
elif [ "$arg" = --help ]; then
usage text
exit 0
elif [ "$arg" = --list-checks ]; then
@@ -128,6 +144,16 @@ main() {
fi
done
if [ -n "$expect_only" ]; then
printf -- '--only requires a check name\n' >&2
exit 2
fi
if [ -n "$only" ] && ! check_exists "$only"; then
printf 'unknown check: %s\n' "$only" >&2
exit 2
fi
if [ -n "$strict" ] && [ -n "$unknown" ]; then
printf 'unknown flag: %s\n' "$unknown" >&2
exit 2
@@ -180,3 +206,5 @@ main() {
}
main "$@"
# Rig: an operator edit made after phase-1 was signed off.