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
|
#!/usr/bin/env bash
|
||||||
# Self-check for orchestra_e2e_healthcheck.sh.
|
# 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"
|
HC="$(dirname "$0")/orchestra_e2e_healthcheck.sh"
|
||||||
OK='OK - all healthchecks passed'
|
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
|
fails=0
|
||||||
|
|
||||||
fail() {
|
check() { # check <expected-stdout> <label> [args...]
|
||||||
printf 'FAIL: %s\n' "$1"
|
|
||||||
fails=$((fails + 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
exact() { # exact <expected-stdout> <label> [args...]
|
|
||||||
local want=$1 label=$2 got status
|
local want=$1 label=$2 got status
|
||||||
shift 2
|
shift 2
|
||||||
got=$(bash "$HC" "$@" 2>/dev/null)
|
got=$(bash "$HC" "$@" 2>/dev/null)
|
||||||
status=$?
|
status=$?
|
||||||
if [ "$got" != "$want" ] || [ "$status" -ne 0 ]; then
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
usage_shape() { # usage_shape <label> [args...]
|
check "$OK" 'no args'
|
||||||
local label=$1 got status flag
|
check '' '--quiet' --quiet
|
||||||
shift
|
check "$USAGE" '--help' --help
|
||||||
got=$(bash "$HC" "$@" 2>/dev/null)
|
check "$USAGE" '--help --quiet' --help --quiet
|
||||||
status=$?
|
check "$USAGE" '--quiet --help' --quiet --help
|
||||||
[ "$status" -eq 0 ] || fail "$label: exit=$status"
|
check "$OK" 'unknown flag ignored' --bogus
|
||||||
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
|
|
||||||
|
|
||||||
[ "$fails" -eq 0 ] || exit 1
|
[ "$fails" -eq 0 ] || exit 1
|
||||||
printf 'all checks passed\n'
|
printf 'all checks passed\n'
|
||||||
|
|||||||
Reference in New Issue
Block a user