summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Nease <stephen.h.nease@gmail.com>2022-10-15 14:36:40 -0500
committerDavid Peter <sharkdp@users.noreply.github.com>2023-03-15 09:33:49 +0100
commitd32b90ee5c86005e6a78be6834de752b1d1bfacd (patch)
tree12844ca4dc9ad898ac0de23c79979b08fae3c366
parentbbb59fd7fa170cccdb8eb7306e717805376095a3 (diff)
Add the rest of the suggestions from code review
-rw-r--r--src/benchmark/executor.rs2
-rw-r--r--src/cli.rs10
-rw-r--r--src/options.rs8
-rw-r--r--tests/integration_tests.rs4
4 files changed, 13 insertions, 11 deletions
diff --git a/src/benchmark/executor.rs b/src/benchmark/executor.rs
index 7d16870..e4fee37 100644
--- a/src/benchmark/executor.rs
+++ b/src/benchmark/executor.rs
@@ -1,4 +1,4 @@
-use std::process::{ExitStatus, Stdio};
+use std::process::ExitStatus;
use crate::command::Command;
use crate::options::{
diff --git a/src/cli.rs b/src/cli.rs
index 9abfc19..c0ae581 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -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"),
)
}
diff --git a/src/options.rs b/src/options.rs
index 08f4074..be226bd 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -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(
diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs
index 810bdf0..ab8d028 100644
--- a/tests/integration_tests.rs
+++ b/tests/integration_tests.rs
@@ -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()