Add the rest of the suggestions from code review

This commit is contained in:
Steve Nease 2022-10-15 14:36:40 -05:00 committed by David Peter
parent bbb59fd7fa
commit d32b90ee5c
4 changed files with 13 additions and 11 deletions

View File

@ -1,4 +1,4 @@
use std::process::{ExitStatus, Stdio};
use std::process::ExitStatus;
use crate::command::Command;
use crate::options::{

View File

@ -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>'.")
)
.arg(
Arg::new("stdin-data")
.long("stdin-data")
Arg::new("input")
.long("input")
.takes_value(true)
.number_of_values(1)
.value_name("FILE")
.help("Path to file containing stdin data to provide to the command"),
.value_name("FROM")
.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"),
)
}

View File

@ -223,14 +223,14 @@ pub struct Options {
/// Determines how we run commands
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
pub command_output_policy: CommandOutputPolicy,
/// Which time unit to use when displaying results
pub time_unit: Option<Unit>,
/// Where input to the benchmarked command comes from
pub command_input_policy: CommandInputPolicy,
}
impl Default for Options {
@ -388,7 +388,7 @@ impl Options {
.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);
if !path.exists() {
return Err(OptionsError::StdinDataFileDoesNotExist(

View File

@ -219,7 +219,7 @@ fn runs_commands_using_user_defined_shell() {
fn can_pass_file_data_to_command_via_stdin() {
hyperfine()
.arg("--runs=1")
.arg("--stdin-data=example_stdin_data")
.arg("--input=example_stdin_data")
.arg("--show-output")
.arg("cat")
.assert()
@ -233,7 +233,7 @@ fn can_pass_file_data_to_command_via_stdin() {
fn fails_if_invalid_stdin_data_file_provided() {
hyperfine()
.arg("--runs=1")
.arg("--stdin-data=example_stdin_data_invalid")
.arg("--input=example_stdin_data_invalid")
.arg("--show-output")
.arg("cat")
.assert()