Add the rest of the suggestions from code review
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Steve Nease · committed by David Peter · parent bbb59fd · Browse files · 4 files·+13 added−11 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+13 added−11 removed
- tests:+2 added−2 removed
- other:+11 added−9 removed
Provenance
- Commit
d32b90e- Tree
12844ca- Author
Steve Nease <stephen.h.nease@gmail.com>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
bbb59fd
4 files changed+13 added−11 removed
modified:src/benchmark/executor.rs+1 added-1 removed
1-use std::process::{ExitStatus, Stdio};1+use std::process::ExitStatus;2 3 use crate::command::Command;4 use crate::options::{5 CmdFailureAction, CommandInputPolicy, CommandOutputPolicy, Options, OutputStyleOption, Shell,294 unmodified linesmodified:src/cli.rs+6 added-4 removed
311 unmodified lines312 .hide(true)313 .help("Enable debug mode which does not actually run commands, but returns fake times when the command is 'sleep <time>'.")314 )315 .arg(316- Arg::new("stdin-data")317- .long("stdin-data")316+ Arg::new("input")317+ .long("input")318 .takes_value(true)319 .number_of_values(1)320- .value_name("FILE")321- .help("Path to file containing stdin data to provide to the command"),320+ .value_name("FROM")321+ .help("Control where the input of the benchmark comes from. <FROM> can be: \322+ null: Read from /edv/null (the default).323+ <FILE>: Read the input from the given file"),324 )325 }326 327 #[test]3 unmodified linesmodified:src/options.rs+4 added-4 removed
221 unmodified lines222 223 /// Determines how we run commands224 pub executor_kind: ExecutorKind,225 226+ /// Where input to the benchmarked command comes from227+ pub command_input_policy: CommandInputPolicy,228+229 /// What to do with the output of the benchmarked command230 pub command_output_policy: CommandOutputPolicy,231 232 /// Which time unit to use when displaying results233 pub time_unit: Option<Unit>,231-232- /// Where input to the benchmarked command comes from233- pub command_input_policy: CommandInputPolicy,234 }235 236 impl Default for Options {237 fn default() -> Options {149 unmodified lines387 .parse::<f64>()388 .map_err(|e| OptionsError::FloatParsingError("min-benchmarking-time", e))?;389 }390 391- options.command_input_policy = if let Some(path_str) = matches.value_of("stdin-data") {391+ options.command_input_policy = if let Some(path_str) = matches.value_of("input") {392 let path = PathBuf::from(path_str);393 if !path.exists() {394 return Err(OptionsError::StdinDataFileDoesNotExist(395 path_str.to_string(),67 unmodified linesmodified:tests/integration_tests.rs+2 added-2 removed
217 unmodified lines218 #[test]219 fn can_pass_file_data_to_command_via_stdin() {220 hyperfine()221 .arg("--runs=1")222- .arg("--stdin-data=example_stdin_data")222+ .arg("--input=example_stdin_data")223 .arg("--show-output")224 .arg("cat")225 .assert()226 .success()5 unmodified lines232 #[test]233 fn fails_if_invalid_stdin_data_file_provided() {234 hyperfine()235 .arg("--runs=1")236- .arg("--stdin-data=example_stdin_data_invalid")236+ .arg("--input=example_stdin_data_invalid")237 .arg("--show-output")238 .arg("cat")239 .assert()240 .failure()109 unmodified lines