Skip to content
Myr

options.rs

This file

Path

src/options.rs

538 lines · 17.3 KiB · Rust

Last changed by

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

History of this file

Take it

The walk stopped after 200 commits: lines older than 0f91d0c point at it.

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 1why, one step back
1use std::fs::File;

Remove dependency on `atty` and use `std::io::IsTerminal` insteadLenabefore adoption69ee173

line 2why, one step back
2use std::io::IsTerminal;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 3–6why, one step back
3use std::path::PathBuf;
4use std::process::{Command, Stdio};5use std::{cmp, env, fmt, io};6

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 7why, one step back
7use anyhow::ensure;

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 8–11why, one step back
8use clap::ArgMatches;
910use crate::command::Commands;11use crate::error::OptionsError;

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 12–13why, one step back
12use crate::metric::{Metric, MetricSelection};
13use crate::quantity::{second, Time};

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 14–35why, one step back
14
15use anyhow::Result;1617#[cfg(not(windows))]18pub const DEFAULT_SHELL: &str = "sh";1920#[cfg(windows)]21pub const DEFAULT_SHELL: &str = "cmd.exe";2223/// Shell to use for executing benchmarked commands24#[derive(Debug, PartialEq)]25pub enum Shell {26 /// Default shell command27 Default(&'static str),2829 /// Custom shell command specified via --shell30 Custom(Vec<String>),31}3233impl fmt::Display for Shell {34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {35 match self {

style: simplify string interpolationHamir Mahalbefore adoptionef12632

line 36why, one step back
36 Shell::Default(cmd) => write!(f, "{cmd}"),

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 37–42why, one step back
37 Shell::Custom(cmdline) => write!(f, "{}", shell_words::join(cmdline)),
38 }39 }40}4142impl Shell {

Make --shell=none the default (#982)David Peterbefore adoptionab86cb9

lines 43–47why, one step back
43 /// Select the platform shell (sh on Unix, cmd.exe on Windows).
44 pub fn platform_default() -> Self {45 Shell::Default(DEFAULT_SHELL)46 }47

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 48–69why, one step back
48 /// Parse given string as shell command line
49 pub fn parse_from_str<'a>(s: &str) -> Result<Self, OptionsError<'a>> {50 let v = shell_words::split(s).map_err(OptionsError::ShellParseError)?;51 if v.is_empty() || v[0].is_empty() {52 return Err(OptionsError::EmptyShell);53 }54 Ok(Shell::Custom(v))55 }5657 pub fn command(&self) -> Command {58 match self {59 Shell::Default(cmd) => Command::new(cmd),60 Shell::Custom(cmdline) => {61 let mut c = Command::new(&cmdline[0]);62 c.args(&cmdline[1..]);63 c64 }65 }66 }67}6869/// Action to take when an executed command fails.

Support list of exit codes in --ignore-failureDavid Peterbefore adoptionb5a6860

line 70why, one step back
70#[derive(Debug, Clone, PartialEq, Eq)]

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 71–74why, one step back
71pub enum CmdFailureAction {
72 /// Exit with an error message73 RaiseError,74

Support list of exit codes in --ignore-failureDavid Peterbefore adoptionb5a6860

lines 75–79why, one step back
75 /// Ignore all non-zero exit codes
76 IgnoreAllFailures,7778 /// Ignore specific exit codes79 IgnoreSpecificFailures(Vec<i32>),

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 80–177why, one step back
80}
8182/// Output style type option83#[derive(Debug, Clone, Copy, PartialEq, Eq)]84pub enum OutputStyleOption {85 /// Do not output with colors or any special formatting86 Basic,8788 /// Output with full color and formatting89 Full,9091 /// Keep elements such as progress bar, but use no coloring92 NoColor,9394 /// Keep coloring, but use no progress bar95 Color,9697 /// Disable all the output98 Disabled,99}100101/// Bounds for the number of benchmark runs102pub struct RunBounds {103 /// Minimum number of benchmark runs104 pub min: u64,105106 /// Maximum number of benchmark runs107 pub max: Option<u64>,108}109110impl Default for RunBounds {111 fn default() -> Self {112 RunBounds { min: 10, max: None }113 }114}115116#[derive(Debug, Default, Clone, PartialEq)]117pub enum CommandInputPolicy {118 /// Read from the null device119 #[default]120 Null,121122 /// Read input from a file123 File(PathBuf),124}125126impl CommandInputPolicy {127 pub fn get_stdin(&self) -> io::Result<Stdio> {128 let stream: Stdio = match self {129 CommandInputPolicy::Null => Stdio::null(),130131 CommandInputPolicy::File(path) => {132 let file: File = File::open(path)?;133 Stdio::from(file)134 }135 };136137 Ok(stream)138 }139}140141/// How to handle the output of benchmarked commands142#[derive(Debug, Clone, PartialEq, Eq, Default)]143pub enum CommandOutputPolicy {144 /// Redirect output to the null device145 #[default]146 Null,147148 /// Feed output through a pipe before discarding it149 Pipe,150151 /// Redirect output to a file152 File(PathBuf),153154 /// Show command output on the terminal155 Inherit,156}157158impl CommandOutputPolicy {159 pub fn get_stdout_stderr(&self) -> io::Result<(Stdio, Stdio)> {160 let streams = match self {161 CommandOutputPolicy::Null => (Stdio::null(), Stdio::null()),162163 // Typically only stdout is performance-relevant, so just pipe that164 CommandOutputPolicy::Pipe => (Stdio::piped(), Stdio::null()),165166 CommandOutputPolicy::File(path) => {167 let file = File::create(path)?;168 (file.into(), Stdio::null())169 }170171 CommandOutputPolicy::Inherit => (Stdio::inherit(), Stdio::inherit()),172 };173174 Ok(streams)175 }176}177

Make --shell=none the default (#982)David Peterbefore adoptionab86cb9

line 178why, one step back
178#[derive(Debug, Default, PartialEq)]

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 179why, one step back
179pub enum ExecutorKind {

Make --shell=none the default (#982)David Peterbefore adoptionab86cb9

line 180why, one step back
180 #[default]

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 181–194why, one step back
181 Raw,
182 Shell(Shell),183 Mock(Option<String>),184}185186/// The main settings for a hyperfine benchmark session187pub struct Options {188 /// Upper and lower bound for the number of benchmark runs189 pub run_bounds: RunBounds,190191 /// Number of warmup runs192 pub warmup_count: u64,193194 /// Minimum benchmarking time

Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c

line 195why, one step back
195 pub min_benchmarking_time: Time,

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 196–199why, one step back
196
197 /// Whether or not to ignore non-zero exit codes198 pub command_failure_action: CmdFailureAction,199

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 200why, one step back
200 /// Command(s) to run before each benchmark run

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 201–202why, one step back
201 pub preparation_command: Option<Vec<String>>,
202

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 203why, one step back
203 /// Command(s) to run after each benchmark run

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 204–205why, one step back
204 pub conclusion_command: Option<Vec<String>>,
205

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 206why, one step back
206 /// Command to run before each *batch* of benchmark runs, i.e. before each individual benchmark

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 207–208why, one step back
207 pub setup_command: Option<String>,
208

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 209why, one step back
209 /// Command to run after each *batch* of benchmark runs, i.e. after each individual benchmark

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 210–220why, one step back
210 pub cleanup_command: Option<String>,
211212 /// What color mode to use for the terminal output213 pub output_style: OutputStyleOption,214215 /// Determines how we run commands216 pub executor_kind: ExecutorKind,217218 /// Where input to the benchmarked command comes from219 pub command_input_policy: CommandInputPolicy,220

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 221–222why, one step back
221 /// What to do with the output of the benchmarked commands
222 pub command_output_policies: Vec<CommandOutputPolicy>,

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 223why, one step back
223

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 224–228why, one step back
224 /// Displayed metrics, with the primary metric first.
225 pub metrics: Vec<MetricSelection>,226227 /// The `all` preset displays only metrics with complete measurements.228 pub skip_unavailable_metrics: bool,

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 229–235why, one step back
229}
230231impl Default for Options {232 fn default() -> Options {233 Options {234 run_bounds: RunBounds::default(),235 warmup_count: 0,

Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c

line 236why, one step back
236 min_benchmarking_time: Time::new::<second>(3.0),

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 237–238why, one step back
237 command_failure_action: CmdFailureAction::RaiseError,
238 preparation_command: None,

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

line 239why, one step back
239 conclusion_command: None,

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 240–243why, one step back
240 setup_command: None,
241 cleanup_command: None,242 output_style: OutputStyleOption::Full,243 executor_kind: ExecutorKind::default(),

Multiple output policiesDavid Peterbefore adoption99d24b7

line 244why, one step back
244 command_output_policies: vec![CommandOutputPolicy::Null],

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 245–247why, one step back
245 metrics: MetricSelection::parse_list(crate::cli::DEFAULT_METRICS)
246 .expect("valid default metrics"),247 skip_unavailable_metrics: false,

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 248–255why, one step back
248 command_input_policy: CommandInputPolicy::Null,
249 }250 }251}252253impl Options {254 pub fn from_cli_arguments<'a>(matches: &ArgMatches) -> Result<Self, OptionsError<'a>> {255 let mut options = Self::default();

Fix panic on --runs 0 (#923)Vincentbefore adoption907de26

lines 256–259why, one step back
256 options.warmup_count = matches
257 .get_one::<u64>("warmup")258 .copied()259 .unwrap_or(options.warmup_count);

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 260why, one step back
260

Fix panic on --runs 0 (#923)Vincentbefore adoption907de26

lines 261–262why, one step back
261 let mut min_runs = matches.get_one::<u64>("min-runs").copied();
262 let mut max_runs = matches.get_one::<u64>("max-runs").copied();

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 263why, one step back
263

Fix panic on --runs 0 (#923)Vincentbefore adoption907de26

line 264why, one step back
264 if let Some(&runs) = matches.get_one::<u64>("runs") {

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 265–288why, one step back
265 min_runs = Some(runs);
266 max_runs = Some(runs);267 }268269 match (min_runs, max_runs) {270 (Some(min), None) => {271 options.run_bounds.min = min;272 }273 (None, Some(max)) => {274 // Since the minimum was not explicit we lower it if max is below the default min.275 options.run_bounds.min = cmp::min(options.run_bounds.min, max);276 options.run_bounds.max = Some(max);277 }278 (Some(min), Some(max)) if min > max => {279 return Err(OptionsError::EmptyRunsRange);280 }281 (Some(min), Some(max)) => {282 options.run_bounds.min = min;283 options.run_bounds.max = Some(max);284 }285 (None, None) => {}286 };287288 options.setup_command = matches.get_one::<String>("setup").map(String::from);

Added option to manually specify a reference to compare the results to.Jan-Eric Nitschkebefore adoption9806ed7

line 289why, one step back
289

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 290–293why, one step back
290 options.preparation_command = matches
291 .get_many::<String>("prepare")292 .map(|values| values.map(String::from).collect::<Vec<String>>());293

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 294–297why, one step back
294 options.conclusion_command = matches
295 .get_many::<String>("conclude")296 .map(|values| values.map(String::from).collect::<Vec<String>>());297

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 298–299why, one step back
298 options.cleanup_command = matches.get_one::<String>("cleanup").map(String::from);
299

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 300–314why, one step back
300 options.command_output_policies = if matches.get_flag("show-output") {
301 vec![CommandOutputPolicy::Inherit]302 } else if let Some(output_values) = matches.get_many::<String>("output") {303 let mut policies = vec![];304 for value in output_values {305 let policy = match value.as_str() {306 "null" => CommandOutputPolicy::Null,307 "pipe" => CommandOutputPolicy::Pipe,308 "inherit" => CommandOutputPolicy::Inherit,309 arg => {310 let path = PathBuf::from(arg);311 if path.components().count() <= 1 {312 return Err(OptionsError::UnknownOutputPolicy(arg.to_string()));313 }314 CommandOutputPolicy::File(path)

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 315why, one step back
315 }

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 316–317why, one step back
316 };
317 policies.push(policy);

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 318why, one step back
318 }

Multiple output policiesDavid Peterbefore adoption99d24b7

line 319why, one step back
319 policies

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 320why, one step back
320 } else {

Multiple output policiesDavid Peterbefore adoption99d24b7

line 321why, one step back
321 vec![CommandOutputPolicy::Null]

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 322–330why, one step back
322 };
323324 options.output_style = match matches.get_one::<String>("style").map(|s| s.as_str()) {325 Some("full") => OutputStyleOption::Full,326 Some("basic") => OutputStyleOption::Basic,327 Some("nocolor") => OutputStyleOption::NoColor,328 Some("color") => OutputStyleOption::Color,329 Some("none") => OutputStyleOption::Disabled,330 _ => {

Multiple output policiesDavid Peterbefore adoption99d24b7

line 331why, one step back
331 if options

FormattingDavid Peterbefore adoptionde07c77

lines 332–333why, one step back
332 .command_output_policies
333 .contains(&CommandOutputPolicy::Inherit)

Remove dependency on `atty` and use `std::io::IsTerminal` insteadLenabefore adoption69ee173

line 334why, one step back
334 || !io::stdout().is_terminal()

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 335–362why, one step back
335 {
336 OutputStyleOption::Basic337 } else if env::var_os("TERM")338 .map(|t| t == "unknown" || t == "dumb")339 .unwrap_or(!cfg!(target_os = "windows"))340 || env::var_os("NO_COLOR")341 .map(|t| !t.is_empty())342 .unwrap_or(false)343 {344 OutputStyleOption::NoColor345 } else {346 OutputStyleOption::Full347 }348 }349 };350351 match options.output_style {352 OutputStyleOption::Basic | OutputStyleOption::NoColor => {353 colored::control::set_override(false)354 }355 OutputStyleOption::Full | OutputStyleOption::Color => {356 colored::control::set_override(true)357 }358 OutputStyleOption::Disabled => {}359 };360361 options.executor_kind = if matches.get_flag("no-shell") {362 ExecutorKind::Raw

Make --shell=none the default (#982)David Peterbefore adoptionab86cb9

lines 363–364why, one step back
363 } else if matches.get_flag("default-shell") {
364 ExecutorKind::Shell(Shell::platform_default())

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 365–369why, one step back
365 } else {
366 match (367 matches.get_flag("debug-mode"),368 matches.get_one::<String>("shell"),369 ) {

Make --shell=none the default (#982)David Peterbefore adoptionab86cb9

lines 370–372why, one step back
370 (false, Some(shell)) if shell == "default" => {
371 ExecutorKind::Shell(Shell::platform_default())372 }

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 373–374why, one step back
373 (false, Some(shell)) if shell == "none" => ExecutorKind::Raw,
374 (false, Some(shell)) => ExecutorKind::Shell(Shell::parse_from_str(shell)?),

Make --shell=none the default (#982)David Peterbefore adoptionab86cb9

line 375why, one step back
375 (false, None) => ExecutorKind::default(),

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 376–380why, one step back
376 (true, Some(shell)) => ExecutorKind::Mock(Some(shell.into())),
377 (true, None) => ExecutorKind::Mock(None),378 }379 };380

Support list of exit codes in --ignore-failureDavid Peterbefore adoptionb5a6860

lines 381–395why, one step back
381 if let Some(mode) = matches.get_one::<String>("ignore-failure") {
382 options.command_failure_action = match mode.as_str() {383 "all-non-zero" | "" => CmdFailureAction::IgnoreAllFailures,384 codes => {385 let exit_codes: Result<Vec<i32>, _> = codes386 .split(',')387 .map(|s| {388 s.trim()389 .parse::<i32>()390 .map_err(|e| OptionsError::IntParsingError("ignore-failure", e))391 })392 .collect();393 CmdFailureAction::IgnoreSpecificFailures(exit_codes?)394 }395 };

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 396–397why, one step back
396 }
397

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 398–427why, one step back
398 match matches.get_one::<String>("metrics").unwrap().as_str() {
399 "default" => {}400 "time" => {401 options.metrics = [402 Metric::TimeWallClock,403 Metric::TimeCpu,404 Metric::TimeUser,405 Metric::TimeSystem,406 ]407 .map(|metric| MetricSelection { metric, unit: None })408 .to_vec();409 }410 "all" => {411 let shell = matches!(412 options.executor_kind,413 ExecutorKind::Shell(_) | ExecutorKind::Mock(Some(_))414 );415 options.metrics = Metric::ALL416 .iter()417 .copied()418 .filter(|metric| metric.ensure_available(shell).is_ok())419 .map(|metric| MetricSelection { metric, unit: None })420 .collect();421 options.skip_unavailable_metrics = true;422 }423 list => {424 options.metrics = MetricSelection::parse_list(list)425 .map_err(|error| OptionsError::InvalidMetrics(error.to_string()))?;426 }427 }

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 428–429why, one step back
428
429 if let Some(time) = matches.get_one::<String>("min-benchmarking-time") {

Merge pull request #961 from sharkdp/codex/uom-quantitiesDavid Peterbefore adoption975a25c

lines 430–433why, one step back
430 options.min_benchmarking_time = Time::new::<second>(
431 time.parse::<f64>()432 .map_err(|e| OptionsError::FloatParsingError("min-benchmarking-time", e))?,433 );

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 434–454why, one step back
434 }
435436 options.command_input_policy = if let Some(path_str) = matches.get_one::<String>("input") {437 if path_str == "null" {438 CommandInputPolicy::Null439 } else {440 let path = PathBuf::from(path_str);441 if !path.exists() {442 return Err(OptionsError::StdinDataFileDoesNotExist(443 path_str.to_string(),444 ));445 }446 CommandInputPolicy::File(path)447 }448 } else {449 CommandInputPolicy::Null450 };451452 Ok(options)453 }454

Multiple output policiesDavid Peterbefore adoption99d24b7

line 455why, one step back
455 pub fn validate_against_command_list(&mut self, commands: &Commands) -> Result<()> {

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

lines 456–460why, one step back
456 if !matches!(self.executor_kind, ExecutorKind::Mock(_)) {
457 for selection in &self.metrics {458 selection459 .metric460 .ensure_available(matches!(self.executor_kind, ExecutorKind::Shell(_)))?;

Merge pull request #979 from sharkdp/fix/parameterized-referenceDavid Peterbefore adoption46e1f9f

lines 461–462why, one step back
461 }
462 }

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 463why, one step back
463 let num_commands = commands.num_commands();

Multiple output policiesDavid Peterbefore adoption99d24b7

line 464why, one step back
464

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 465–466why, one step back
465 if let Some(preparation_command) = &self.preparation_command {
466 ensure!(

Fix prepare and conclude behaviour and add tests.Jan-Eric Nitschkebefore adoptiond4749b0

line 467why, one step back
467 preparation_command.len() <= 1 || num_commands == preparation_command.len(),

Multiple output policiesDavid Peterbefore adoption99d24b7

line 468why, one step back
468 "The '--prepare' option has to be provided just once or N times, where N={num_commands} is the \

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 469why, one step back
469 number of benchmark commands."

Add --conclude option with testsJack O'Connorbefore adoptione13d0cb

lines 470–474why, one step back
470 );
471 }472473 if let Some(conclusion_command) = &self.conclusion_command {474 ensure!(

Fix prepare and conclude behaviour and add tests.Jan-Eric Nitschkebefore adoptiond4749b0

line 475why, one step back
475 conclusion_command.len() <= 1 || num_commands == conclusion_command.len(),

Multiple output policiesDavid Peterbefore adoption99d24b7

line 476why, one step back
476 "The '--conclude' option has to be provided just once or N times, where N={num_commands} is the \

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 477why, one step back
477 number of benchmark commands."

Multiple output policiesDavid Peterbefore adoption99d24b7

lines 478–487why, one step back
478 );
479 }480481 if self.command_output_policies.len() == 1 {482 self.command_output_policies =483 vec![self.command_output_policies[0].clone(); num_commands];484 } else {485 ensure!(486 self.command_output_policies.len() == num_commands,487 "The '--output' option has to be provided just once or N times, where N={num_commands} is the \

Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9

line 488why, one step back
488 number of benchmark commands."

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 489–496why, one step back
489 );
490 }491492 Ok(())493 }494}495496#[test]

Make --shell=none the default (#982)David Peterbefore adoptionab86cb9

lines 497–498why, one step back
497fn test_platform_default_shell() {
498 let shell = Shell::platform_default();

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

line 499why, one step back
499

style: simplify string interpolationHamir Mahalbefore adoptionef12632

line 500why, one step back
500 let s = format!("{shell}");

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 501–510why, one step back
501 assert_eq!(&s, DEFAULT_SHELL);
502503 let cmd = shell.command();504 assert_eq!(cmd.get_program(), DEFAULT_SHELL);505}506507#[test]508fn test_can_parse_shell_command_line_from_str() {509 let shell = Shell::parse_from_str("shell -x 'aaa bbb'").unwrap();510

style: simplify string interpolationHamir Mahalbefore adoptionef12632

line 511why, one step back
511 let s = format!("{shell}");

Bump serde from 1.0.174 to 1.0.179dependabot[bot]before adoption0f91d0c

lines 512–538why, one step back
512 assert_eq!(&s, "shell -x 'aaa bbb'");
513514 let cmd = shell.command();515 assert_eq!(cmd.get_program().to_string_lossy(), "shell");516 assert_eq!(517 cmd.get_args()518 .map(|a| a.to_string_lossy())519 .collect::<Vec<_>>(),520 vec!["-x", "aaa bbb"]521 );522523 // Error cases524 assert!(matches!(525 Shell::parse_from_str("shell 'foo").unwrap_err(),526 OptionsError::ShellParseError(_)527 ));528529 assert!(matches!(530 Shell::parse_from_str("").unwrap_err(),531 OptionsError::EmptyShell532 ));533534 assert!(matches!(535 Shell::parse_from_str("''").unwrap_err(),536 OptionsError::EmptyShell537 ));538}