Skip to content
Myr

Rename parse to from_str

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Peter · committed by David Peter · parent 0ebd76d · Browse files · 1 file+8 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−8 removed

  • other:+8 added−8 removed

1 file+8 added−8 removed

modified:src/options.rs+8 added-8 removed
42 unmodified lines
43}4445impl Shell {46 /// Parse given string as shell command line47 pub fn parse<'a>(s: &str) -> Result<Self, OptionsError<'a>> {47 pub fn from_str<'a>(s: &str) -> Result<Self, OptionsError<'a>> {48 let v = shell_words::split(s).map_err(OptionsError::ShellParseError)?;49 if v.is_empty() || v[0].is_empty() {50 return Err(OptionsError::EmptyShell);51 }
85 unmodified lines
137138 /// Whether or not to ignore non-zero exit codes139 pub command_failure_action: CmdFailureAction,140141 /// Command to run before each timing run141 /// Command(s) to run before each timing run142 pub preparation_command: Option<Vec<String>>,143144 /// Command to run before each *batch* of timing runs, i.e. before each individual benchmark145 pub setup_command: Option<String>,
121 unmodified lines
267 OutputStyleOption::Disabled => {}268 };269270 if let Some(shell) = matches.value_of("shell") {271 options.shell = Shell::parse(shell)?;271 options.shell = Shell::from_str(shell)?;272 }273274 if matches.is_present("ignore-failure") {275 options.command_failure_action = CmdFailureAction::Ignore;
36 unmodified lines
312 assert_eq!(s, format!("\"{}\"", DEFAULT_SHELL));313}314315#[test]316fn test_shell_parse_command() {317 let shell = Shell::parse("shell -x 'aaa bbb'").unwrap();316fn test_can_parse_shell_command_line_from_str() {317 let shell = Shell::from_str("shell -x 'aaa bbb'").unwrap();318319 let s = format!("{}", shell);320 assert_eq!(&s, "shell -x 'aaa bbb'");321
7 unmodified lines
329 );330331 // Error cases332 assert!(matches!(333 Shell::parse("shell 'foo").unwrap_err(),333 Shell::from_str("shell 'foo").unwrap_err(),334 OptionsError::ShellParseError(_)335 ));336337 assert!(matches!(338 Shell::parse("").unwrap_err(),338 Shell::from_str("").unwrap_err(),339 OptionsError::EmptyShell340 ));341342 assert!(matches!(343 Shell::parse("''").unwrap_err(),343 Shell::from_str("''").unwrap_err(),344 OptionsError::EmptyShell345 ));346}