mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 17:11:28 +00:00
Rename to get_command_line
This commit is contained in:
1 parent
defafdf707
commit
826449bc8f
2 files changed
+14
-14
No files matched your search
@@ -61,7 +61,7 @@ impl<'a> Executor for ShellExecutor<'a> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let wallclock_timer = WallClockTimer::start();
|
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_command_line(), self.shell)?;
|
||||||
let mut time_real = wallclock_timer.stop();
|
let mut time_real = wallclock_timer.stop();
|
||||||
|
|
||||||
let mut time_user = result.user_time;
|
let mut time_user = result.user_time;
|
||||||
@@ -202,7 +202,7 @@ impl Executor for MockExecutor {
|
|||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
TimingResult {
|
TimingResult {
|
||||||
time_real: Self::extract_time(command.get_shell_command()),
|
time_real: Self::extract_time(command.get_command_line()),
|
||||||
time_user: 0.0,
|
time_user: 0.0,
|
||||||
time_system: 0.0,
|
time_system: 0.0,
|
||||||
},
|
},
|
||||||
|
|||||||
+12
-12
@@ -55,12 +55,12 @@ impl<'a> Command<'a> {
|
|||||||
|
|
||||||
pub fn get_name(&self) -> String {
|
pub fn get_name(&self) -> String {
|
||||||
self.name.map_or_else(
|
self.name.map_or_else(
|
||||||
|| self.get_shell_command(),
|
|| self.get_command_line(),
|
||||||
|name| self.replace_parameters_in(name),
|
|name| self.replace_parameters_in(name),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_shell_command(&self) -> String {
|
pub fn get_command_line(&self) -> String {
|
||||||
self.replace_parameters_in(self.expression)
|
self.replace_parameters_in(self.expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ impl<'a> Command<'a> {
|
|||||||
//
|
//
|
||||||
// hyperfine -L foo 'a,{bar}' -L bar 'baz,quux' 'echo {foo} {bar}'
|
// hyperfine -L foo 'a,{bar}' -L bar 'baz,quux' 'echo {foo} {bar}'
|
||||||
//
|
//
|
||||||
// should not ever run 'echo baz baz'. See `test_get_shell_command_nonoverlapping`.
|
// should not ever run 'echo baz baz'. See `test_get_command_line_nonoverlapping`.
|
||||||
'outer: while let Some(head) = remaining.chars().next() {
|
'outer: while let Some(head) = remaining.chars().next() {
|
||||||
for (k, v) in &replacements {
|
for (k, v) in &replacements {
|
||||||
if remaining.starts_with(k.as_str()) {
|
if remaining.starts_with(k.as_str()) {
|
||||||
@@ -318,7 +318,7 @@ impl<'a> Commands<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_get_shell_command_nonoverlapping() {
|
fn test_get_command_line_nonoverlapping() {
|
||||||
let cmd = Command::new_parametrized(
|
let cmd = Command::new_parametrized(
|
||||||
None,
|
None,
|
||||||
"echo {foo} {bar}",
|
"echo {foo} {bar}",
|
||||||
@@ -327,7 +327,7 @@ fn test_get_shell_command_nonoverlapping() {
|
|||||||
("bar", ParameterValue::Text("quux".into())),
|
("bar", ParameterValue::Text("quux".into())),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
assert_eq!(cmd.get_shell_command(), "echo {bar} baz quux");
|
assert_eq!(cmd.get_command_line(), "echo {bar} baz quux");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -345,7 +345,7 @@ fn test_get_parameterized_command_name() {
|
|||||||
|
|
||||||
impl<'a> fmt::Display for Command<'a> {
|
impl<'a> fmt::Display for Command<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", self.get_shell_command())
|
write!(f, "{}", self.get_command_line())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,8 +404,8 @@ fn test_build_parameter_list_commands() {
|
|||||||
assert_eq!(commands.len(), 2);
|
assert_eq!(commands.len(), 2);
|
||||||
assert_eq!(commands[0].get_name(), "name-1");
|
assert_eq!(commands[0].get_name(), "name-1");
|
||||||
assert_eq!(commands[1].get_name(), "name-2");
|
assert_eq!(commands[1].get_name(), "name-2");
|
||||||
assert_eq!(commands[0].get_shell_command(), "echo 1");
|
assert_eq!(commands[0].get_command_line(), "echo 1");
|
||||||
assert_eq!(commands[1].get_shell_command(), "echo 2");
|
assert_eq!(commands[1].get_command_line(), "echo 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -427,8 +427,8 @@ fn test_build_parameter_scan_commands() {
|
|||||||
assert_eq!(commands.len(), 2);
|
assert_eq!(commands.len(), 2);
|
||||||
assert_eq!(commands[0].get_name(), "name-1");
|
assert_eq!(commands[0].get_name(), "name-1");
|
||||||
assert_eq!(commands[1].get_name(), "name-2");
|
assert_eq!(commands[1].get_name(), "name-2");
|
||||||
assert_eq!(commands[0].get_shell_command(), "echo 1");
|
assert_eq!(commands[0].get_command_line(), "echo 1");
|
||||||
assert_eq!(commands[1].get_shell_command(), "echo 2");
|
assert_eq!(commands[1].get_command_line(), "echo 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -444,7 +444,7 @@ fn test_parameter_scan_commands_int() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(commands.len(), 3);
|
assert_eq!(commands.len(), 3);
|
||||||
assert_eq!(commands[2].get_name(), "echo 7");
|
assert_eq!(commands[2].get_name(), "echo 7");
|
||||||
assert_eq!(commands[2].get_shell_command(), "echo 7");
|
assert_eq!(commands[2].get_command_line(), "echo 7");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -464,7 +464,7 @@ fn test_parameter_scan_commands_decimal() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(commands.len(), 4);
|
assert_eq!(commands.len(), 4);
|
||||||
assert_eq!(commands[3].get_name(), "echo 0.99");
|
assert_eq!(commands[3].get_name(), "echo 0.99");
|
||||||
assert_eq!(commands[3].get_shell_command(), "echo 0.99");
|
assert_eq!(commands[3].get_command_line(), "echo 0.99");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in new issue
Block a user