orchestra: pre-release WIP snapshot (orchestra-06g54dzygp30qxm4sxdb1nf1e0-6f2befa5)
This commit is contained in:
@@ -12,6 +12,8 @@ shebang_is_bash usage_text_mentions_every_flag"
|
||||
|
||||
# name=ok / name=fail pairs, in run order.
|
||||
RESULTS=
|
||||
# name=ms pairs, in run order.
|
||||
TIMES=
|
||||
FAILED=0
|
||||
TOTAL=0
|
||||
|
||||
@@ -82,7 +84,7 @@ usage() {
|
||||
emit "$1" ' --quiet Suppress the success message; still exits 0.\n'
|
||||
emit "$1" ' --json Print a single-line JSON result; still exits 0.\n'
|
||||
emit "$1" ' --help Print this usage text and exit 0.\n'
|
||||
emit "$1" ' --summary Print one line per check before the success message.\n'
|
||||
emit "$1" ' --summary Print one line per check before the success message, then the slowest check after it.\n'
|
||||
emit "$1" ' --timing Print elapsed milliseconds for the run.\n'
|
||||
emit "$1" ' --strict Reject an unrecognised flag: exits 2.\n'
|
||||
emit "$1" ' --list-checks Print the name of each check; exits 0.\n'
|
||||
@@ -133,13 +135,15 @@ main() {
|
||||
exit 2
|
||||
fi
|
||||
|
||||
local name
|
||||
local name check_start
|
||||
for name in $CHECKS; do
|
||||
check_start=$(now_us)
|
||||
if "check_$name"; then
|
||||
record "$name" ok
|
||||
else
|
||||
record "$name" fail
|
||||
fi
|
||||
TIMES="$TIMES $name=$(elapsed_ms "$check_start")"
|
||||
done
|
||||
|
||||
local format=text
|
||||
@@ -176,6 +180,19 @@ main() {
|
||||
fi
|
||||
|
||||
emit "$format" '%s\n' "$SUCCESS_MESSAGE"
|
||||
|
||||
if [ -n "$summary" ]; then
|
||||
local slow_name= slow_ms=-1 ms
|
||||
for entry in $TIMES; do
|
||||
ms=${entry#*=}
|
||||
if [ "$ms" -gt "$slow_ms" ]; then
|
||||
slow_ms=$ms
|
||||
slow_name=${entry%=*}
|
||||
fi
|
||||
done
|
||||
emit "$format" 'slowest: %s (%sms)\n' "$slow_name" "$slow_ms"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user