mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-11-23 04:19:03 +03:00
64 lines
1.3 KiB
Rust
64 lines
1.3 KiB
Rust
mod common;
|
|
use common::hyperfine;
|
|
|
|
use predicates::prelude::*;
|
|
|
|
#[test]
|
|
fn hyperfine_runs_successfully() {
|
|
hyperfine()
|
|
.arg("--runs=2")
|
|
.arg("echo dummy benchmark")
|
|
.assert()
|
|
.success();
|
|
}
|
|
|
|
#[test]
|
|
fn one_run_is_supported() {
|
|
hyperfine()
|
|
.arg("--runs=1")
|
|
.arg("echo dummy benchmark")
|
|
.assert()
|
|
.success();
|
|
}
|
|
|
|
#[test]
|
|
fn fails_with_wrong_number_of_command_name_arguments() {
|
|
hyperfine()
|
|
.arg("--command-name=a")
|
|
.arg("--command-name=b")
|
|
.arg("echo a")
|
|
.assert()
|
|
.failure()
|
|
.stderr(predicate::str::contains("Too many --command-name options"));
|
|
}
|
|
|
|
#[test]
|
|
fn fails_for_unknown_command() {
|
|
hyperfine()
|
|
.arg("some-nonexisting-program-b5d9574198b7e4b12a71fa4747c0a577")
|
|
.assert()
|
|
.failure()
|
|
.stderr(predicate::str::contains(
|
|
"Command terminated with non-zero exit code",
|
|
));
|
|
}
|
|
|
|
#[cfg(unix)]
|
|
#[test]
|
|
fn can_run_failing_commands_with_ignore_failure_option() {
|
|
hyperfine()
|
|
.arg("false")
|
|
.assert()
|
|
.failure()
|
|
.stderr(predicate::str::contains(
|
|
"Command terminated with non-zero exit code",
|
|
));
|
|
|
|
hyperfine()
|
|
.arg("--runs=1")
|
|
.arg("--ignore-failure")
|
|
.arg("false")
|
|
.assert()
|
|
.success();
|
|
}
|