orchestra: pre-release WIP snapshot (orchestra-06g4gbsq2wrgd5hgypyzz4tyh0-ec8111ad)
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Flag parsing for orchestra_e2e_healthcheck.sh. Sourced, not executed.
|
||||||
|
# parse_flags sets quiet, json and strict; it exits 0 on --help, and exits 1
|
||||||
|
# under --strict on the first unrecognised argument.
|
||||||
|
|
||||||
|
parse_flags() {
|
||||||
|
quiet=
|
||||||
|
json=
|
||||||
|
strict=
|
||||||
|
unset unknown
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [ "$arg" = --help ]; then
|
||||||
|
printf 'Usage: %s [--quiet]\n\n' "${0##*/}"
|
||||||
|
printf 'Healthcheck script for Orchestra E2E tests.\n'
|
||||||
|
printf 'Exits 0 with a success message if all checks pass.\n'
|
||||||
|
printf ' --quiet Suppress the success message; still exits 0.\n'
|
||||||
|
exit 0
|
||||||
|
elif [ "$arg" = --quiet ]; then
|
||||||
|
quiet=1
|
||||||
|
elif [ "$arg" = --json ]; then
|
||||||
|
json=1
|
||||||
|
elif [ "$arg" = --strict ]; then
|
||||||
|
strict=1
|
||||||
|
else
|
||||||
|
# Keep the first unrecognised argument only. ${unknown+x} tests set-ness,
|
||||||
|
# so an empty-string argument is recorded too.
|
||||||
|
[ -n "${unknown+x}" ] || unknown=$arg
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Deferred past the loop so --help still wins from any position.
|
||||||
|
if [ -n "$strict" ] && [ -n "${unknown+x}" ]; then
|
||||||
|
printf 'unknown flag: %s\n' "$unknown" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
@@ -1,32 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
main() {
|
. "$(dirname "$0")/flags.sh"
|
||||||
local quiet=
|
|
||||||
local json=
|
|
||||||
local strict=
|
|
||||||
local unknown=
|
|
||||||
for arg in "$@"; do
|
|
||||||
if [ "$arg" = --help ]; then
|
|
||||||
printf 'Usage: %s [--quiet]\n\n' "${0##*/}"
|
|
||||||
printf 'Healthcheck script for Orchestra E2E tests.\n'
|
|
||||||
printf 'Exits 0 with a success message if all checks pass.\n'
|
|
||||||
printf ' --quiet Suppress the success message; still exits 0.\n'
|
|
||||||
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
|
main() {
|
||||||
printf 'unknown flag: %s\n' "$unknown" >&2
|
parse_flags "$@"
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$json" ]; then
|
if [ -n "$json" ]; then
|
||||||
printf '{"status":"ok","checks":1}\n'
|
printf '{"status":"ok","checks":1}\n'
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ esac
|
|||||||
sout=$(bash "$healthcheck" --strict --nonsense 2>&1)
|
sout=$(bash "$healthcheck" --strict --nonsense 2>&1)
|
||||||
sstatus=$?
|
sstatus=$?
|
||||||
|
|
||||||
[ "$sstatus" -eq 2 ] || fail "--strict --nonsense exit status: want 2, got $sstatus" "$sout"
|
[ "$sstatus" -eq 1 ] || fail "--strict --nonsense exit status: want 1, got $sstatus" "$sout"
|
||||||
|
|
||||||
# --strict alone is accepted
|
# --strict alone is accepted
|
||||||
gout=$(bash "$healthcheck" --strict)
|
gout=$(bash "$healthcheck" --strict)
|
||||||
@@ -46,4 +46,10 @@ gstatus=$?
|
|||||||
|
|
||||||
[ "$gstatus" -eq 0 ] || fail "--strict run exit status: want 0, got $gstatus" "$gout"
|
[ "$gstatus" -eq 0 ] || fail "--strict run exit status: want 0, got $gstatus" "$gout"
|
||||||
|
|
||||||
|
# --strict rejects an empty-string argument too
|
||||||
|
eout=$(bash "$healthcheck" --strict "" 2>&1)
|
||||||
|
estatus=$?
|
||||||
|
|
||||||
|
[ "$estatus" -eq 1 ] || fail "--strict '' exit status: want 1, got $estatus" "$eout"
|
||||||
|
|
||||||
printf 'selftest: ok\n'
|
printf 'selftest: ok\n'
|
||||||
|
|||||||
Reference in New Issue
Block a user