mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-11-22 11:43:03 +03:00
Fix clippy warnings
This commit is contained in:
parent
b6ff23a77f
commit
f029a46ff9
@ -62,7 +62,7 @@ impl<'a> Executor for ShellExecutor<'a> {
|
||||
};
|
||||
|
||||
let wallclock_timer = WallClockTimer::start();
|
||||
let result = execute_and_time(stdout, stderr, &command.get_shell_command(), &self.shell)?;
|
||||
let result = execute_and_time(stdout, stderr, &command.get_shell_command(), self.shell)?;
|
||||
let mut time_real = wallclock_timer.stop();
|
||||
|
||||
let mut time_user = result.user_time;
|
||||
|
@ -34,7 +34,7 @@ impl<'a> Scheduler<'a> {
|
||||
pub fn run_benchmarks(&mut self) -> Result<()> {
|
||||
let mut executor: Box<dyn Executor> = match self.options.executor_kind {
|
||||
ExecutorKind::Mock(ref shell) => Box::new(MockExecutor::new(shell.clone())),
|
||||
ExecutorKind::Shell(ref shell) => Box::new(ShellExecutor::new(shell, &self.options)),
|
||||
ExecutorKind::Shell(ref shell) => Box::new(ShellExecutor::new(shell, self.options)),
|
||||
};
|
||||
|
||||
executor.calibrate()?;
|
||||
|
@ -44,7 +44,7 @@ impl fmt::Display for Shell {
|
||||
|
||||
impl Shell {
|
||||
/// Parse given string as shell command line
|
||||
pub fn from_str<'a>(s: &str) -> Result<Self, OptionsError<'a>> {
|
||||
pub fn parse_from_str<'a>(s: &str) -> Result<Self, OptionsError<'a>> {
|
||||
let v = shell_words::split(s).map_err(OptionsError::ShellParseError)?;
|
||||
if v.is_empty() || v[0].is_empty() {
|
||||
return Err(OptionsError::EmptyShell);
|
||||
@ -274,7 +274,7 @@ impl Options {
|
||||
|
||||
options.executor_kind = match (matches.is_present("debug-mode"), matches.value_of("shell"))
|
||||
{
|
||||
(false, Some(shell)) => ExecutorKind::Shell(Shell::from_str(shell)?),
|
||||
(false, Some(shell)) => ExecutorKind::Shell(Shell::parse_from_str(shell)?),
|
||||
(false, None) => ExecutorKind::Shell(Shell::default()),
|
||||
(true, Some(shell)) => ExecutorKind::Mock(Some(shell.into())),
|
||||
(true, None) => ExecutorKind::Mock(None),
|
||||
@ -320,7 +320,7 @@ fn test_default_shell() {
|
||||
|
||||
#[test]
|
||||
fn test_can_parse_shell_command_line_from_str() {
|
||||
let shell = Shell::from_str("shell -x 'aaa bbb'").unwrap();
|
||||
let shell = Shell::parse_from_str("shell -x 'aaa bbb'").unwrap();
|
||||
|
||||
let s = format!("{}", shell);
|
||||
assert_eq!(&s, "shell -x 'aaa bbb'");
|
||||
@ -336,17 +336,17 @@ fn test_can_parse_shell_command_line_from_str() {
|
||||
|
||||
// Error cases
|
||||
assert!(matches!(
|
||||
Shell::from_str("shell 'foo").unwrap_err(),
|
||||
Shell::parse_from_str("shell 'foo").unwrap_err(),
|
||||
OptionsError::ShellParseError(_)
|
||||
));
|
||||
|
||||
assert!(matches!(
|
||||
Shell::from_str("").unwrap_err(),
|
||||
Shell::parse_from_str("").unwrap_err(),
|
||||
OptionsError::EmptyShell
|
||||
));
|
||||
|
||||
assert!(matches!(
|
||||
Shell::from_str("''").unwrap_err(),
|
||||
Shell::parse_from_str("''").unwrap_err(),
|
||||
OptionsError::EmptyShell
|
||||
));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user