Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ec0502f829 | |||
| 7d04aef94d | |||
| 172c100dec | |||
| 94bd45c3b5 | |||
| ec320c8240 | |||
| ba0e891348 | |||
| 56d9b9acdd | |||
| 14654d6cab |
@@ -1,14 +1,42 @@
|
||||
# Task 06G4E6F69AKP2PA00S28D7ASBC
|
||||
# Task 06G4GBSQ2WRGD5HGYPYZZ4TYH0
|
||||
|
||||
Add a --quiet flag to the healthcheck script
|
||||
Add a --strict mode to the healthcheck
|
||||
|
||||
- Project: test-e2e
|
||||
- Source: gitea:test-e2e/7
|
||||
- Source: gitea:test-e2e/13
|
||||
- Priority: 0
|
||||
|
||||
## Instructions
|
||||
|
||||
scripts/orchestra_e2e_healthcheck.sh already handles --help. Add a --quiet flag alongside it that suppresses the success line and still exits 0. Leave the default behaviour and the --help output unchanged.
|
||||
Three phases, in this order.
|
||||
|
||||
## Phase 1 — `--strict` on the healthcheck
|
||||
|
||||
`scripts/orchestra_e2e_healthcheck.sh --strict` must reject an unrecognised flag: print `unknown flag: <flag>` on stderr and exit 2. Without `--strict` the current silent-ignore behaviour is unchanged, and `--help` still wins from any position.
|
||||
|
||||
## Phase 2 — cover `--strict` in the existing self-test
|
||||
|
||||
Extend `scripts/orchestra_e2e_selftest.sh`, which already asserts the plain and `--json` runs. Add assertions that `--strict --nonsense` exits 2 and that `--strict` alone exits 0. Keep its existing `fail()` helper and its existing assertions.
|
||||
|
||||
## Phase 3 — keep the pinned usage text honest
|
||||
|
||||
`scripts/test_healthcheck.sh` pins the healthcheck's exact `--help` output in a hardcoded `USAGE` variable. Phase 1 changes nothing about `--help`, so this phase only confirms the pin still holds.
|
||||
|
||||
Verify this phase by running the pinned test itself:
|
||||
|
||||
- run: ["bash", "scripts/test_healthcheck.sh"]
|
||||
|
||||
## Constraints
|
||||
|
||||
The project's verification policy allows exactly two command shapes:
|
||||
|
||||
["bash", "-n", "<one file>"]
|
||||
["bash", "scripts/orchestra_e2e_healthcheck.sh"]
|
||||
|
||||
## Research first
|
||||
|
||||
Establish at least three findings with distinct confidence: at least one `fact`, one `inference`, one `assumption`. Cite at least two in References.
|
||||
|
||||
|
||||
## Completion
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
main() {
|
||||
local quiet=
|
||||
local json=
|
||||
local strict=
|
||||
local unknown=
|
||||
for arg in "$@"; do
|
||||
if [ "$arg" = --help ]; then
|
||||
printf 'Usage: %s [--quiet]\n\n' "${0##*/}"
|
||||
@@ -11,9 +14,25 @@ main() {
|
||||
exit 0
|
||||
elif [ "$arg" = --quiet ]; then
|
||||
quiet=1
|
||||
elif [ "$arg" = --json ]; then
|
||||
json=1
|
||||
elif [ "$arg" = --strict ]; then
|
||||
strict=1
|
||||
else
|
||||
[ -n "$unknown" ] || unknown=$arg
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$strict" ] && [ -n "$unknown" ]; then
|
||||
printf 'unknown flag: %s\n' "$unknown" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ -n "$json" ]; then
|
||||
printf '{"status":"ok","checks":1}\n'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
[ -n "$quiet" ] || printf 'OK - all healthchecks passed\n'
|
||||
exit 0
|
||||
}
|
||||
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
# Self-test for the Orchestra E2E healthcheck.
|
||||
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
healthcheck="$here/orchestra_e2e_healthcheck.sh"
|
||||
|
||||
# fail <assertion> <captured stdout>: always echo what the healthcheck printed,
|
||||
# so a red run is diagnosable without rerunning it by hand.
|
||||
fail() {
|
||||
printf 'selftest: FAILED %s\n' "$1" >&2
|
||||
printf 'selftest: healthcheck stdout was:\n%s\n' "$2" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# plain run
|
||||
out=$(bash "$healthcheck")
|
||||
status=$?
|
||||
|
||||
[ "$status" -eq 0 ] || fail "plain run exit status: want 0, got $status" "$out"
|
||||
case "$out" in
|
||||
*OK*) ;;
|
||||
*) fail "plain run stdout contains OK" "$out" ;;
|
||||
esac
|
||||
|
||||
# --json run
|
||||
jout=$(bash "$healthcheck" --json)
|
||||
jstatus=$?
|
||||
|
||||
[ "$jstatus" -eq 0 ] || fail "--json run exit status: want 0, got $jstatus" "$jout"
|
||||
jlines=$(printf '%s\n' "$jout" | wc -l)
|
||||
[ "$jlines" -eq 1 ] || fail "--json run line count: want 1, got $jlines" "$jout"
|
||||
case "$jout" in
|
||||
'{"status":'*) ;;
|
||||
*) fail '--json run stdout prefix: want {"status":' "$jout" ;;
|
||||
esac
|
||||
|
||||
# --strict rejects an unknown flag
|
||||
sout=$(bash "$healthcheck" --strict --nonsense 2>&1)
|
||||
sstatus=$?
|
||||
|
||||
[ "$sstatus" -eq 2 ] || fail "--strict --nonsense exit status: want 2, got $sstatus" "$sout"
|
||||
|
||||
# --strict alone is accepted
|
||||
gout=$(bash "$healthcheck" --strict)
|
||||
gstatus=$?
|
||||
|
||||
[ "$gstatus" -eq 0 ] || fail "--strict run exit status: want 0, got $gstatus" "$gout"
|
||||
|
||||
printf 'selftest: ok\n'
|
||||
Reference in New Issue
Block a user