mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 17:11:28 +00:00
Add the rest of the suggestions from code review
This commit is contained in:
1 parent
bbb59fd7fa
commit
d32b90ee5c
4 files changed
+13
-11
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
use std::process::{ExitStatus, Stdio};
|
use std::process::ExitStatus;
|
||||||
|
|
||||||
use crate::command::Command;
|
use crate::command::Command;
|
||||||
use crate::options::{
|
use crate::options::{
|
||||||
|
|||||||
+6
-4
@@ -313,12 +313,14 @@ fn build_command() -> Command {
|
|||||||
.help("Enable debug mode which does not actually run commands, but returns fake times when the command is 'sleep <time>'.")
|
.help("Enable debug mode which does not actually run commands, but returns fake times when the command is 'sleep <time>'.")
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("stdin-data")
|
Arg::new("input")
|
||||||
.long("stdin-data")
|
.long("input")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.number_of_values(1)
|
.number_of_values(1)
|
||||||
.value_name("FILE")
|
.value_name("FROM")
|
||||||
.help("Path to file containing stdin data to provide to the command"),
|
.help("Control where the input of the benchmark comes from. <FROM> can be: \
|
||||||
|
null: Read from /edv/null (the default).
|
||||||
|
<FILE>: Read the input from the given file"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -223,14 +223,14 @@ pub struct Options {
|
|||||||
/// Determines how we run commands
|
/// Determines how we run commands
|
||||||
pub executor_kind: ExecutorKind,
|
pub executor_kind: ExecutorKind,
|
||||||
|
|
||||||
|
/// Where input to the benchmarked command comes from
|
||||||
|
pub command_input_policy: CommandInputPolicy,
|
||||||
|
|
||||||
/// What to do with the output of the benchmarked command
|
/// What to do with the output of the benchmarked command
|
||||||
pub command_output_policy: CommandOutputPolicy,
|
pub command_output_policy: CommandOutputPolicy,
|
||||||
|
|
||||||
/// Which time unit to use when displaying results
|
/// Which time unit to use when displaying results
|
||||||
pub time_unit: Option<Unit>,
|
pub time_unit: Option<Unit>,
|
||||||
|
|
||||||
/// Where input to the benchmarked command comes from
|
|
||||||
pub command_input_policy: CommandInputPolicy,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Options {
|
impl Default for Options {
|
||||||
@@ -388,7 +388,7 @@ impl Options {
|
|||||||
.map_err(|e| OptionsError::FloatParsingError("min-benchmarking-time", e))?;
|
.map_err(|e| OptionsError::FloatParsingError("min-benchmarking-time", e))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
options.command_input_policy = if let Some(path_str) = matches.value_of("stdin-data") {
|
options.command_input_policy = if let Some(path_str) = matches.value_of("input") {
|
||||||
let path = PathBuf::from(path_str);
|
let path = PathBuf::from(path_str);
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
return Err(OptionsError::StdinDataFileDoesNotExist(
|
return Err(OptionsError::StdinDataFileDoesNotExist(
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ fn runs_commands_using_user_defined_shell() {
|
|||||||
fn can_pass_file_data_to_command_via_stdin() {
|
fn can_pass_file_data_to_command_via_stdin() {
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("--stdin-data=example_stdin_data")
|
.arg("--input=example_stdin_data")
|
||||||
.arg("--show-output")
|
.arg("--show-output")
|
||||||
.arg("cat")
|
.arg("cat")
|
||||||
.assert()
|
.assert()
|
||||||
@@ -233,7 +233,7 @@ fn can_pass_file_data_to_command_via_stdin() {
|
|||||||
fn fails_if_invalid_stdin_data_file_provided() {
|
fn fails_if_invalid_stdin_data_file_provided() {
|
||||||
hyperfine()
|
hyperfine()
|
||||||
.arg("--runs=1")
|
.arg("--runs=1")
|
||||||
.arg("--stdin-data=example_stdin_data_invalid")
|
.arg("--input=example_stdin_data_invalid")
|
||||||
.arg("--show-output")
|
.arg("--show-output")
|
||||||
.arg("cat")
|
.arg("cat")
|
||||||
.assert()
|
.assert()
|
||||||
|
|||||||
Reference in new issue
Block a user