🤔 Background
bashunit::benchmark::parse_annotations extracts each marker with a numeric sed pattern and falls back to the default when the pattern does not match. A malformed value is therefore indistinguishable from an absent annotation, and the benchmark silently runs with different parameters than the ones written.
$ cat y_bench.sh
# @revs=abc
function bench_x() { :; }
$ ./bashunit bench .
Name Revs Its Avg(ms)
bench_x 1 1 9 # asked for N revolutions, ran 1
$ echo $?
0
Same for @its=abc (runs 1 iteration) and @max_ms=abc (threshold dropped entirely, so the benchmark can never fail).
This is the same class as #871/#873/#875/#877/#879: input that cannot be parsed is discarded rather than reported, and the run reports success having done something other than what was asked.
Suggested fix
Treat "marker present but no value extracted" as an error. An absent annotation keeps its default; a malformed one aborts with a message naming the marker.
Note the call site discards the status: read -r revs its max_ms <<<"$(parse_annotations ...)" cannot see a non-zero return from the command substitution, so it needs to capture into a variable first.
Found while closing out the silent-failure class.
🤔 Background
bashunit::benchmark::parse_annotationsextracts each marker with a numericsedpattern and falls back to the default when the pattern does not match. A malformed value is therefore indistinguishable from an absent annotation, and the benchmark silently runs with different parameters than the ones written.Same for
@its=abc(runs 1 iteration) and@max_ms=abc(threshold dropped entirely, so the benchmark can never fail).This is the same class as #871/#873/#875/#877/#879: input that cannot be parsed is discarded rather than reported, and the run reports success having done something other than what was asked.
Suggested fix
Treat "marker present but no value extracted" as an error. An absent annotation keeps its default; a malformed one aborts with a message naming the marker.
Note the call site discards the status:
read -r revs its max_ms <<<"$(parse_annotations ...)"cannot see a non-zero return from the command substitution, so it needs to capture into a variable first.Found while closing out the silent-failure class.