Skip to content
Myr

command.rs

This file

Path

src/command.rs

522 lines · 16.2 KiB · Rust

Last changed by

Rename to get_command_lineDavid Peterbefore adoption826449b

History of this file

Take it

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 1–2why, one step back
1use std::collections::BTreeMap;
2use std::fmt;

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

line 3why, one step back
3use std::str::FromStr;

Flat directory/module structureDavid Peterbefore adoption30c381f

line 4why, one step back
4

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

lines 5–6why, one step back
5use crate::{
6 error::{OptionsError, ParameterScanError},

Move functions into SchedulerDavid Peterbefore adoption39c7736

lines 7–10why, one step back
7 parameter::{
8 range_step::{Numeric, RangeStep},9 ParameterNameAndValue,10 },

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

line 11why, one step back
11};

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 12–14why, one step back
12
13use clap::ArgMatches;14

New parameter moduleDavid Peterbefore adoption47091a5

lines 15–16why, one step back
15use crate::parameter::tokenize::tokenize;
16use crate::parameter::ParameterValue;

Flat directory/module structureDavid Peterbefore adoption30c381f

line 17why, one step back
17

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 18why, one step back
18use anyhow::{bail, Result};

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

lines 19–20why, one step back
19use clap::Values;
20use rust_decimal::Decimal;

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 21why, one step back
21

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 22–31why, one step back
22/// A command that should be benchmarked.
23#[derive(Debug, Clone, PartialEq, Eq)]24pub struct Command<'a> {25 /// The command name (without parameter substitution)26 name: Option<&'a str>,2728 /// The command that should be executed (without parameter substitution)29 expression: &'a str,3031 /// Zero or more parameter values.

Move functions into SchedulerDavid Peterbefore adoption39c7736

line 32why, one step back
32 parameters: Vec<ParameterNameAndValue<'a>>,

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 33–46why, one step back
33}
3435impl<'a> Command<'a> {36 pub fn new(name: Option<&'a str>, expression: &'a str) -> Command<'a> {37 Command {38 name,39 expression,40 parameters: Vec::new(),41 }42 }4344 pub fn new_parametrized(45 name: Option<&'a str>,46 expression: &'a str,

Move functions into SchedulerDavid Peterbefore adoption39c7736

line 47why, one step back
47 parameters: impl IntoIterator<Item = ParameterNameAndValue<'a>>,

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 48–51why, one step back
48 ) -> Command<'a> {
49 Command {50 name,51 expression,

Move functions into SchedulerDavid Peterbefore adoption39c7736

line 52why, one step back
52 parameters: parameters.into_iter().collect(),

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 53–57why, one step back
53 }
54 }5556 pub fn get_name(&self) -> String {57 self.name.map_or_else(

Rename to get_command_lineDavid Peterbefore adoption826449b

line 58why, one step back
58 || self.get_command_line(),

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 59–62why, one step back
59 |name| self.replace_parameters_in(name),
60 )61 }62

Rename to get_command_lineDavid Peterbefore adoption826449b

line 63why, one step back
63 pub fn get_command_line(&self) -> String {

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 64–66why, one step back
64 self.replace_parameters_in(self.expression)
65 }66

Move functions into SchedulerDavid Peterbefore adoption39c7736

line 67why, one step back
67 pub fn get_parameters(&self) -> &[(&'a str, ParameterValue)] {

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 68–84why, one step back
68 &self.parameters
69 }7071 fn replace_parameters_in(&self, original: &str) -> String {72 let mut result = String::new();73 let mut replacements = BTreeMap::<String, String>::new();74 for (param_name, param_value) in &self.parameters {75 replacements.insert(76 format!("{{{param_name}}}", param_name = param_name),77 param_value.to_string(),78 );79 }80 let mut remaining = original;81 // Manually replace consecutive occurrences to avoid double-replacing: e.g.,82 //83 // hyperfine -L foo 'a,{bar}' -L bar 'baz,quux' 'echo {foo} {bar}'84 //

Rename to get_command_lineDavid Peterbefore adoption826449b

line 85why, one step back
85 // should not ever run 'echo baz baz'. See `test_get_command_line_nonoverlapping`.

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 86–100why, one step back
86 'outer: while let Some(head) = remaining.chars().next() {
87 for (k, v) in &replacements {88 if remaining.starts_with(k.as_str()) {89 result.push_str(v);90 remaining = &remaining[k.len()..];91 continue 'outer;92 }93 }94 result.push(head);95 remaining = &remaining[head.len_utf8()..];96 }97 result98 }99}100

Refactor command.rsDavid Peterbefore adoption833529f

line 101why, one step back
101/// A collection of commands that should be benchmarked

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 102why, one step back
102pub struct Commands<'a>(Vec<Command<'a>>);

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 103why, one step back
103

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 104–110why, one step back
104impl<'a> Commands<'a> {
105 pub fn from_cli_arguments(matches: &'a ArgMatches) -> Result<Commands> {106 let command_names = matches.values_of("command-name");107 let command_strings = matches.values_of("command").unwrap();108109 if let Some(args) = matches.values_of("parameter-scan") {110 let step_size = matches.value_of("parameter-step-size");

Refactor command.rsDavid Peterbefore adoption833529f

line 111why, one step back
111 Ok(Self(Self::get_parameter_scan_commands(

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 112–130why, one step back
112 command_names,
113 command_strings,114 args,115 step_size,116 )?))117 } else if let Some(args) = matches.values_of("parameter-list") {118 let command_names = command_names.map_or(vec![], |names| names.collect::<Vec<&str>>());119120 let args: Vec<_> = args.collect();121 let param_names_and_values: Vec<(&str, Vec<String>)> = args122 .chunks_exact(2)123 .map(|pair| {124 let name = pair[0];125 let list_str = pair[1];126 (name, tokenize(list_str))127 })128 .collect();129 {130 let duplicates =

Refactor command.rsDavid Peterbefore adoption833529f

line 131why, one step back
131 Self::find_duplicates(param_names_and_values.iter().map(|(name, _)| *name));

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 132–134why, one step back
132 if !duplicates.is_empty() {
133 bail!("Duplicate parameter names: {}", &duplicates.join(", "));134 }

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 135why, one step back
135 }

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 136why, one step back
136 let command_list = command_strings.collect::<Vec<&str>>();

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 137why, one step back
137

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 138–148why, one step back
138 let dimensions: Vec<usize> = std::iter::once(command_list.len())
139 .chain(140 param_names_and_values141 .iter()142 .map(|(_, values)| values.len()),143 )144 .collect();145 let param_space_size = dimensions.iter().product();146 if param_space_size == 0 {147 return Ok(Self(Vec::new()));148 }

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 149why, one step back
149

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 150–159why, one step back
150 // `--command-name` should appear exactly once or exactly B times,
151 // where B is the total number of benchmarks.152 let command_name_count = command_names.len();153 if command_name_count > 1 && command_name_count != param_space_size {154 return Err(OptionsError::UnexpectedCommandNameCount(155 command_name_count,156 param_space_size,157 )158 .into());159 }

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 160why, one step back
160

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 161–169why, one step back
161 let mut i = 0;
162 let mut commands = Vec::with_capacity(param_space_size);163 let mut index = vec![0usize; dimensions.len()];164 'outer: loop {165 let name = command_names166 .get(i)167 .or_else(|| command_names.get(0))168 .copied();169 i += 1;

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 170why, one step back
170

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 171why, one step back
171 let (command_index, params_indices) = index.split_first().unwrap();

Move functions into SchedulerDavid Peterbefore adoption39c7736

line 172why, one step back
172 let parameters: Vec<_> = param_names_and_values

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 173–181why, one step back
173 .iter()
174 .zip(params_indices)175 .map(|((name, values), i)| (*name, ParameterValue::Text(values[*i].clone())))176 .collect();177 commands.push(Command::new_parametrized(178 name,179 command_list[*command_index],180 parameters,181 ));

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 182why, one step back
182

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 183–190why, one step back
183 // Increment index, exiting loop on overflow.
184 for (i, n) in index.iter_mut().zip(dimensions.iter()) {185 *i += 1;186 if *i < *n {187 continue 'outer;188 } else {189 *i = 0;190 }

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 191why, one step back
191 }

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 192why, one step back
192 break 'outer;

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 193–194why, one step back
193 }
194

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 195–200why, one step back
195 Ok(Self(commands))
196 } else {197 let command_names = command_names.map_or(vec![], |names| names.collect::<Vec<&str>>());198 if command_names.len() > command_strings.len() {199 return Err(OptionsError::TooManyCommandNames(command_strings.len()).into());200 }

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 201why, one step back
201

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 202–207why, one step back
202 let command_list = command_strings.collect::<Vec<&str>>();
203 let mut commands = Vec::with_capacity(command_list.len());204 for (i, s) in command_list.iter().enumerate() {205 commands.push(Command::new(command_names.get(i).copied(), s));206 }207 Ok(Self(commands))

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 208–210why, one step back
208 }
209 }210

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 211–212why, one step back
211 pub fn iter(&self) -> impl Iterator<Item = &Command<'a>> {
212 self.0.iter()

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 213why, one step back
213 }

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 214why, one step back
214

Fix clippy warningDavid Peterbefore adoption250db61

line 215why, one step back
215 pub fn num_commands(&self) -> usize {

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 216–217why, one step back
216 self.0.len()
217 }

Refactor command.rsDavid Peterbefore adoption833529f

lines 218–317why, one step back
218
219 /// Finds all the strings that appear multiple times in the input iterator, returning them in220 /// sorted order. If no string appears more than once, the result is an empty vector.221 fn find_duplicates<'b, I: IntoIterator<Item = &'b str>>(i: I) -> Vec<&'b str> {222 let mut counts = BTreeMap::<&'b str, usize>::new();223 for s in i {224 *counts.entry(s).or_default() += 1;225 }226 counts227 .into_iter()228 .filter_map(|(k, n)| if n > 1 { Some(k) } else { None })229 .collect()230 }231232 fn build_parameter_scan_commands<'b, T: Numeric>(233 param_name: &'b str,234 param_min: T,235 param_max: T,236 step: T,237 command_names: Vec<&'b str>,238 command_strings: Vec<&'b str>,239 ) -> Result<Vec<Command<'b>>, ParameterScanError> {240 let param_range = RangeStep::new(param_min, param_max, step)?;241 let param_count = param_range.size_hint().1.unwrap();242 let command_name_count = command_names.len();243244 // `--command-name` should appear exactly once or exactly B times,245 // where B is the total number of benchmarks.246 if command_name_count > 1 && command_name_count != param_count {247 return Err(ParameterScanError::UnexpectedCommandNameCount(248 command_name_count,249 param_count,250 ));251 }252253 let mut i = 0;254 let mut commands = vec![];255 for value in param_range {256 for cmd in &command_strings {257 let name = command_names258 .get(i)259 .or_else(|| command_names.get(0))260 .copied();261 commands.push(Command::new_parametrized(262 name,263 cmd,264 vec![(param_name, ParameterValue::Numeric(value.into()))],265 ));266 i += 1;267 }268 }269 Ok(commands)270 }271272 fn get_parameter_scan_commands<'b>(273 command_names: Option<Values<'b>>,274 command_strings: Values<'b>,275 mut vals: clap::Values<'b>,276 step: Option<&str>,277 ) -> Result<Vec<Command<'b>>, ParameterScanError> {278 let command_names = command_names.map_or(vec![], |names| names.collect::<Vec<&str>>());279 let command_strings = command_strings.collect::<Vec<&str>>();280 let param_name = vals.next().unwrap();281 let param_min = vals.next().unwrap();282 let param_max = vals.next().unwrap();283284 // attempt to parse as integers285 if let (Ok(param_min), Ok(param_max), Ok(step)) = (286 param_min.parse::<i32>(),287 param_max.parse::<i32>(),288 step.unwrap_or("1").parse::<i32>(),289 ) {290 return Self::build_parameter_scan_commands(291 param_name,292 param_min,293 param_max,294 step,295 command_names,296 command_strings,297 );298 }299300 // try parsing them as decimals301 let param_min = Decimal::from_str(param_min)?;302 let param_max = Decimal::from_str(param_max)?;303304 if step.is_none() {305 return Err(ParameterScanError::StepRequired);306 }307308 let step = Decimal::from_str(step.unwrap())?;309 Self::build_parameter_scan_commands(310 param_name,311 param_min,312 param_max,313 step,314 command_names,315 command_strings,316 )317 }

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 318–319why, one step back
318}
319

Flat directory/module structureDavid Peterbefore adoption30c381f

line 320why, one step back
320#[test]

Rename to get_command_lineDavid Peterbefore adoption826449b

line 321why, one step back
321fn test_get_command_line_nonoverlapping() {

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 322–329why, one step back
322 let cmd = Command::new_parametrized(
323 None,324 "echo {foo} {bar}",325 vec![326 ("foo", ParameterValue::Text("{bar} baz".into())),327 ("bar", ParameterValue::Text("quux".into())),328 ],329 );

Rename to get_command_lineDavid Peterbefore adoption826449b

line 330why, one step back
330 assert_eq!(cmd.get_command_line(), "echo {bar} baz quux");

Flat directory/module structureDavid Peterbefore adoption30c381f

lines 331–347why, one step back
331}
332333#[test]334fn test_get_parameterized_command_name() {335 let cmd = Command::new_parametrized(336 Some("name-{bar}-{foo}"),337 "echo {foo} {bar}",338 vec![339 ("foo", ParameterValue::Text("baz".into())),340 ("bar", ParameterValue::Text("quux".into())),341 ],342 );343 assert_eq!(cmd.get_name(), "name-quux-baz");344}345346impl<'a> fmt::Display for Command<'a> {347 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

Rename to get_command_lineDavid Peterbefore adoption826449b

line 348why, one step back
348 write!(f, "{}", self.get_command_line())

Flat directory/module structureDavid Peterbefore adoption30c381f

line 349why, one step back
349 }

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 350–353why, one step back
350}
351352#[test]353fn test_build_commands_cross_product() {

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 354why, one step back
354 use crate::app::get_cli_arguments;

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 355why, one step back
355

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 356why, one step back
356 let matches = get_cli_arguments(vec![

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 357–366why, one step back
357 "hyperfine",
358 "-L",359 "par1",360 "a,b",361 "-L",362 "par2",363 "z,y",364 "echo {par1} {par2}",365 "printf '%s\n' {par1} {par2}",366 ]);

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 367why, one step back
367 let result = Commands::from_cli_arguments(&matches).unwrap().0;

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 368–391why, one step back
368
369 // Iteration order: command list first, then parameters in listed order (here, "par1" before370 // "par2", which is distinct from their sorted order), with parameter values in listed order.371 let pv = |s: &str| ParameterValue::Text(s.to_string());372 let cmd = |cmd: usize, par1: &str, par2: &str| {373 let expression = ["echo {par1} {par2}", "printf '%s\n' {par1} {par2}"][cmd];374 let params = vec![("par1", pv(par1)), ("par2", pv(par2))];375 Command::new_parametrized(None, expression, params)376 };377 let expected = vec![378 cmd(0, "a", "z"),379 cmd(1, "a", "z"),380 cmd(0, "b", "z"),381 cmd(1, "b", "z"),382 cmd(0, "a", "y"),383 cmd(1, "a", "y"),384 cmd(0, "b", "y"),385 cmd(1, "b", "y"),386 ];387 assert_eq!(result, expected);388}389390#[test]391fn test_build_parameter_list_commands() {

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 392why, one step back
392 use crate::app::get_cli_arguments;

Move build_commandsDavid Peterbefore adoptioncd38e9c

line 393why, one step back
393

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 394why, one step back
394 let matches = get_cli_arguments(vec![

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 395–402why, one step back
395 "hyperfine",
396 "echo {foo}",397 "--parameter-list",398 "foo",399 "1,2",400 "--command-name",401 "name-{foo}",402 ]);

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 403why, one step back
403 let commands = Commands::from_cli_arguments(&matches).unwrap().0;

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 404–406why, one step back
404 assert_eq!(commands.len(), 2);
405 assert_eq!(commands[0].get_name(), "name-1");406 assert_eq!(commands[1].get_name(), "name-2");

Rename to get_command_lineDavid Peterbefore adoption826449b

lines 407–408why, one step back
407 assert_eq!(commands[0].get_command_line(), "echo 1");
408 assert_eq!(commands[1].get_command_line(), "echo 2");

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 409–411why, one step back
409}
410411#[test]

Refactor command.rsDavid Peterbefore adoption833529f

line 412why, one step back
412fn test_build_parameter_scan_commands() {

Introduce Commands structDavid Peterbefore adoptiona6baf49

lines 413–414why, one step back
413 use crate::app::get_cli_arguments;
414 let matches = get_cli_arguments(vec![

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 415–425why, one step back
415 "hyperfine",
416 "echo {val}",417 "--parameter-scan",418 "val",419 "1",420 "2",421 "--parameter-step-size",422 "1",423 "--command-name",424 "name-{val}",425 ]);

Introduce Commands structDavid Peterbefore adoptiona6baf49

line 426why, one step back
426 let commands = Commands::from_cli_arguments(&matches).unwrap().0;

Move build_commandsDavid Peterbefore adoptioncd38e9c

lines 427–429why, one step back
427 assert_eq!(commands.len(), 2);
428 assert_eq!(commands[0].get_name(), "name-1");429 assert_eq!(commands[1].get_name(), "name-2");

Rename to get_command_lineDavid Peterbefore adoption826449b

lines 430–431why, one step back
430 assert_eq!(commands[0].get_command_line(), "echo 1");
431 assert_eq!(commands[1].get_command_line(), "echo 2");

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

lines 432–434why, one step back
432}
433434#[test]

Refactor command.rsDavid Peterbefore adoption833529f

lines 435–444why, one step back
435fn test_parameter_scan_commands_int() {
436 let commands = Commands::build_parameter_scan_commands(437 "val",438 1i32,439 7i32,440 3i32,441 vec![],442 vec!["echo {val}"],443 )444 .unwrap();

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

lines 445–446why, one step back
445 assert_eq!(commands.len(), 3);
446 assert_eq!(commands[2].get_name(), "echo 7");

Rename to get_command_lineDavid Peterbefore adoption826449b

line 447why, one step back
447 assert_eq!(commands[2].get_command_line(), "echo 7");

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

lines 448–450why, one step back
448}
449450#[test]

Refactor command.rsDavid Peterbefore adoption833529f

line 451why, one step back
451fn test_parameter_scan_commands_decimal() {

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

lines 452–455why, one step back
452 let param_min = Decimal::from_str("0").unwrap();
453 let param_max = Decimal::from_str("1").unwrap();454 let step = Decimal::from_str("0.33").unwrap();455

Refactor command.rsDavid Peterbefore adoption833529f

lines 456–457why, one step back
456 let commands = Commands::build_parameter_scan_commands(
457 "val",

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

lines 458–466why, one step back
458 param_min,
459 param_max,460 step,461 vec![],462 vec!["echo {val}"],463 )464 .unwrap();465 assert_eq!(commands.len(), 4);466 assert_eq!(commands[3].get_name(), "echo 0.99");

Rename to get_command_lineDavid Peterbefore adoption826449b

line 467why, one step back
467 assert_eq!(commands[3].get_command_line(), "echo 0.99");

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

lines 468–470why, one step back
468}
469470#[test]

Refactor command.rsDavid Peterbefore adoption833529f

lines 471–473why, one step back
471fn test_parameterr_scan_commands_names() {
472 let commands = Commands::build_parameter_scan_commands(473 "val",

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

lines 474–490why, one step back
474 1i32,
475 3i32,476 1i32,477 vec!["name-{val}"],478 vec!["echo {val}"],479 )480 .unwrap();481 assert_eq!(commands.len(), 3);482 let command_names = commands483 .iter()484 .map(|c| c.get_name())485 .collect::<Vec<String>>();486 assert_eq!(command_names, vec!["name-1", "name-2", "name-3"]);487}488489#[test]490fn test_get_specified_command_names() {

Refactor command.rsDavid Peterbefore adoption833529f

lines 491–492why, one step back
491 let commands = Commands::build_parameter_scan_commands(
492 "val",

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

lines 493–509why, one step back
493 1i32,
494 3i32,495 1i32,496 vec!["name-a", "name-b", "name-c"],497 vec!["echo {val}"],498 )499 .unwrap();500 assert_eq!(commands.len(), 3);501 let command_names = commands502 .iter()503 .map(|c| c.get_name())504 .collect::<Vec<String>>();505 assert_eq!(command_names, vec!["name-a", "name-b", "name-c"]);506}507508#[test]509fn test_different_command_name_count_with_parameters() {

Refactor command.rsDavid Peterbefore adoption833529f

lines 510–511why, one step back
510 let result = Commands::build_parameter_scan_commands(
511 "val",

Split range into range_step and commandsDavid Peterbefore adoption6db82cd

lines 512–517why, one step back
512 1i32,
513 3i32,514 1i32,515 vec!["name-1", "name-2"],516 vec!["echo {val}"],517 );

Refactor command.rsDavid Peterbefore adoption833529f

lines 518–521why, one step back
518 assert!(matches!(
519 result.unwrap_err(),520 ParameterScanError::UnexpectedCommandNameCount(2, 3)521 ));

Flat directory/module structureDavid Peterbefore adoption30c381f

line 522why, one step back
522}