Restore the byte-pinned USAGE test_healthcheck.sh from master
7d04aef replaced the byte-exact USAGE pin with a shape check that requires
every long flag grepped from the healthcheck source to appear in --help.
--json was already undocumented before this task, so that check was red on
arrival and it also dropped the 'unknown flag ignored' assertion on --bogus,
the only pin on the no---strict silent-ignore path.
The accepted plan's phase 3 is 'no edit': --help is untouched by --strict, so
master's version passes as-is.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+10
-36
@@ -1,54 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# Self-check for orchestra_e2e_healthcheck.sh.
|
||||
#
|
||||
# The pinned USAGE string is gone. Pinning the help text byte for byte meant
|
||||
# every flag added to the healthcheck turned this file red for a reason that
|
||||
# had nothing to do with the flag. The usage assertions now check shape: --help
|
||||
# must print a Usage: line, must document every long flag the script actually
|
||||
# parses, and must exit 0 from any argument position.
|
||||
|
||||
HC="$(dirname "$0")/orchestra_e2e_healthcheck.sh"
|
||||
OK='OK - all healthchecks passed'
|
||||
USAGE="$(printf 'Usage: orchestra_e2e_healthcheck.sh [--quiet]\n\nHealthcheck script for Orchestra E2E tests.\nExits 0 with a success message if all checks pass.\n --quiet Suppress the success message; still exits 0.')"
|
||||
fails=0
|
||||
|
||||
fail() {
|
||||
printf 'FAIL: %s\n' "$1"
|
||||
fails=$((fails + 1))
|
||||
}
|
||||
|
||||
exact() { # exact <expected-stdout> <label> [args...]
|
||||
check() { # check <expected-stdout> <label> [args...]
|
||||
local want=$1 label=$2 got status
|
||||
shift 2
|
||||
got=$(bash "$HC" "$@" 2>/dev/null)
|
||||
status=$?
|
||||
if [ "$got" != "$want" ] || [ "$status" -ne 0 ]; then
|
||||
fail "$label (exit=$status, got: $got)"
|
||||
printf 'FAIL: %s (exit=%s)\n---got---\n%s\n---want---\n%s\n' "$label" "$status" "$got" "$want"
|
||||
fails=$((fails + 1))
|
||||
fi
|
||||
}
|
||||
|
||||
usage_shape() { # usage_shape <label> [args...]
|
||||
local label=$1 got status flag
|
||||
shift
|
||||
got=$(bash "$HC" "$@" 2>/dev/null)
|
||||
status=$?
|
||||
[ "$status" -eq 0 ] || fail "$label: exit=$status"
|
||||
case "$got" in
|
||||
Usage:*) ;;
|
||||
*) fail "$label: no Usage: line" ;;
|
||||
esac
|
||||
for flag in $(grep -o -- '--[a-z][a-z-]*' "$HC" | sort -u); do
|
||||
case "$got" in
|
||||
*"$flag"*) ;;
|
||||
*) fail "$label: $flag is parsed but undocumented" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
exact "$OK" 'no args'
|
||||
exact '' '--quiet' --quiet
|
||||
usage_shape '--help' --help
|
||||
usage_shape '--help --quiet' --help --quiet
|
||||
usage_shape '--quiet --help' --quiet --help
|
||||
check "$OK" 'no args'
|
||||
check '' '--quiet' --quiet
|
||||
check "$USAGE" '--help' --help
|
||||
check "$USAGE" '--help --quiet' --help --quiet
|
||||
check "$USAGE" '--quiet --help' --quiet --help
|
||||
check "$OK" 'unknown flag ignored' --bogus
|
||||
|
||||
[ "$fails" -eq 0 ] || exit 1
|
||||
printf 'all checks passed\n'
|
||||
|
||||
Reference in New Issue
Block a user