Skip to content
Myr

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

4 files+13 added−11 removed

modified:src/benchmark/executor.rs+1 added-1 removed
1use std::process::{ExitStatus, Stdio};1use std::process::ExitStatus;23use crate::command::Command;4use crate::options::{5 CmdFailureAction, CommandInputPolicy, CommandOutputPolicy, Options, OutputStyleOption, Shell,
294 unmodified lines
modified:src/cli.rs+6 added-4 removed
311 unmodified lines
312 .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}326327#[test]
3 unmodified lines
modified:src/options.rs+4 added-4 removed
221 unmodified lines
222223 /// Determines how we run commands224 pub executor_kind: ExecutorKind,225226 /// Where input to the benchmarked command comes from227 pub command_input_policy: CommandInputPolicy,228229 /// What to do with the output of the benchmarked command230 pub command_output_policy: CommandOutputPolicy,231232 /// Which time unit to use when displaying results233 pub time_unit: Option<Unit>,231232 /// Where input to the benchmarked command comes from233 pub command_input_policy: CommandInputPolicy,234}235236impl Default for Options {237 fn default() -> Options {
149 unmodified lines
387 .parse::<f64>()388 .map_err(|e| OptionsError::FloatParsingError("min-benchmarking-time", e))?;389 }390391 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 lines
modified:tests/integration_tests.rs+2 added-2 removed
217 unmodified lines
218#[test]219fn 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 lines
232#[test]233fn 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