tools: add diagnostic in v repeat for invalid combinations of -r, -i and -a flags

This commit is contained in:
Delyan Angelov 2024-09-03 07:46:26 +03:00
parent da228e93df
commit b898987ece
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED

View file

@ -362,7 +362,7 @@ fn (mut context Context) show_summary_title(line string) {
if context.nmaxs > 0 {
msg << 'discard maxs: ${context.nmaxs:2}'
}
if context.current_run > 0 {
if context.repeats_count > 1 {
msg << 'repeat: ${context.current_run:2}'
}
println(msg.join(', '))
@ -407,6 +407,13 @@ fn (mut context Context) parse_options() ! {
}
context.commands = context.expand_all_commands(commands)
context.reset_results()
if context.nmins >= context.run_count {
context.error_no_run_counts_to_report('${context.run_count - 1} bottom results with `-i ${context.nmins}`')
} else if context.nmaxs >= context.run_count {
context.error_no_run_counts_to_report('${context.run_count - 1} top results with `-a ${context.nmaxs}`')
} else if context.nmaxs + context.nmins >= context.run_count {
context.error_no_run_counts_to_report('${context.nmaxs + context.nmins - 1} results with `-i ${context.nmins}` and `-a ${context.nmaxs}`')
}
if context.use_newline {
context.cline = '\n'
context.cgoback = '\n'
@ -416,6 +423,10 @@ fn (mut context Context) parse_options() ! {
}
}
fn (mut context Context) error_no_run_counts_to_report(detail string) {
eprintln('${bold('Warning:')} discarding more than ${detail}, with only `-r ${context.run_count}` runs, will leave you with no results to report at all.')
}
fn (mut context Context) reset_results() {
context.results = []CmdResult{len: context.commands.len, cap: 20, init: CmdResult{
outputs: []string{cap: 500}