mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 01:00:31 +00:00
Fix panic on --runs 0 (#923)
* fix: reject --runs/--max-runs 0, clamp --min-runs to 1 * Validate positive run counts with clap --------- Co-authored-by: VXNCXNX <VXNCXNX@users.noreply.github.com> Co-authored-by: David Peter <mail@david-peter.de>
This commit is contained in:
3 files changed
+37
-14
No files matched your search
@@ -74,6 +74,32 @@ fn exits_quietly_when_stdout_is_closed() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fails_with_zero_runs() {
|
||||
for option in ["--runs", "--min-runs", "--max-runs"] {
|
||||
hyperfine()
|
||||
.arg(option)
|
||||
.arg("0")
|
||||
.arg("echo dummy benchmark")
|
||||
.assert()
|
||||
.code(2)
|
||||
.stderr(predicate::str::contains(format!(
|
||||
"invalid value '0' for '{option} <NUM>'"
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn min_runs_of_one_still_performs_one_run() {
|
||||
hyperfine_debug()
|
||||
.arg("--min-runs=1")
|
||||
.arg("--warmup=0")
|
||||
.arg("sleep 4")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("Time (abs ≡)"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_run_commands_without_a_shell() {
|
||||
hyperfine()
|
||||
|
||||
Reference in new issue
Block a user