mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 17:00:18 +00:00
Add --conclude option with tests
This implementation of --conclude is basically identical to the existing implementation for --prepare. I have not adapted any existing tests. All tests which test --conclude functionality are new. The --conclude commands will run in the same order in which they are supplied on the cli in the same manner as --prepare and there must either be one --conclude command, or else the same number of --concludes as there are commands.
This commit is contained in:
1 parent
91388e7302
commit
e13d0cb144
5 files changed
+239
-2
No files matched your search
@@ -207,6 +207,9 @@ pub struct Options {
|
||||
/// Command(s) to run before each timing run
|
||||
pub preparation_command: Option<Vec<String>>,
|
||||
|
||||
/// Command(s) to run after each timing run
|
||||
pub conclusion_command: Option<Vec<String>>,
|
||||
|
||||
/// Command to run before each *batch* of timing runs, i.e. before each individual benchmark
|
||||
pub setup_command: Option<String>,
|
||||
|
||||
@@ -243,6 +246,7 @@ impl Default for Options {
|
||||
min_benchmarking_time: 3.0,
|
||||
command_failure_action: CmdFailureAction::RaiseError,
|
||||
preparation_command: None,
|
||||
conclusion_command: None,
|
||||
setup_command: None,
|
||||
cleanup_command: None,
|
||||
output_style: OutputStyleOption::Full,
|
||||
@@ -304,6 +308,10 @@ impl Options {
|
||||
.get_many::<String>("prepare")
|
||||
.map(|values| values.map(String::from).collect::<Vec<String>>());
|
||||
|
||||
options.conclusion_command = matches
|
||||
.get_many::<String>("conclude")
|
||||
.map(|values| values.map(String::from).collect::<Vec<String>>());
|
||||
|
||||
options.cleanup_command = matches.get_one::<String>("cleanup").map(String::from);
|
||||
|
||||
options.command_output_policy = if matches.get_flag("show-output") {
|
||||
@@ -432,6 +440,15 @@ impl Options {
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(conclusion_command) = &self.conclusion_command {
|
||||
ensure!(
|
||||
conclusion_command.len() <= 1
|
||||
|| commands.num_commands() == conclusion_command.len(),
|
||||
"The '--conclude' option has to be provided just once or N times, where N is the \
|
||||
number of benchmark commands."
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user