mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 01:00:31 +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
@@ -54,6 +54,11 @@ impl ExecutionOrderTest {
|
||||
self.command(output)
|
||||
}
|
||||
|
||||
fn conclude(&mut self, output: &str) -> &mut Self {
|
||||
self.arg("--conclude");
|
||||
self.command(output)
|
||||
}
|
||||
|
||||
fn cleanup(&mut self, output: &str) -> &mut Self {
|
||||
self.arg("--cleanup");
|
||||
self.command(output)
|
||||
@@ -160,6 +165,24 @@ fn prepare_commands_are_executed_before_each_timing_run() {
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn conclude_commands_are_executed_after_each_timing_run() {
|
||||
ExecutionOrderTest::new()
|
||||
.arg("--runs=2")
|
||||
.conclude("conclude")
|
||||
.command("command 1")
|
||||
.command("command 2")
|
||||
.expect_output("command 1")
|
||||
.expect_output("conclude")
|
||||
.expect_output("command 1")
|
||||
.expect_output("conclude")
|
||||
.expect_output("command 2")
|
||||
.expect_output("conclude")
|
||||
.expect_output("command 2")
|
||||
.expect_output("conclude")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prepare_commands_are_executed_before_each_warmup() {
|
||||
ExecutionOrderTest::new()
|
||||
@@ -187,6 +210,33 @@ fn prepare_commands_are_executed_before_each_warmup() {
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn conclude_commands_are_executed_after_each_warmup() {
|
||||
ExecutionOrderTest::new()
|
||||
.arg("--warmup=2")
|
||||
.arg("--runs=1")
|
||||
.conclude("conclude")
|
||||
.command("command 1")
|
||||
.command("command 2")
|
||||
// warmup 1
|
||||
.expect_output("command 1")
|
||||
.expect_output("conclude")
|
||||
.expect_output("command 1")
|
||||
.expect_output("conclude")
|
||||
// benchmark 1
|
||||
.expect_output("command 1")
|
||||
.expect_output("conclude")
|
||||
// warmup 2
|
||||
.expect_output("command 2")
|
||||
.expect_output("conclude")
|
||||
.expect_output("command 2")
|
||||
.expect_output("conclude")
|
||||
// benchmark 2
|
||||
.expect_output("command 2")
|
||||
.expect_output("conclude")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cleanup_commands_are_executed_once_after_each_benchmark() {
|
||||
ExecutionOrderTest::new()
|
||||
@@ -234,6 +284,44 @@ fn setup_prepare_cleanup_combined() {
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn setup_prepare_conclude_cleanup_combined() {
|
||||
ExecutionOrderTest::new()
|
||||
.arg("--warmup=1")
|
||||
.arg("--runs=2")
|
||||
.setup("setup")
|
||||
.prepare("prepare")
|
||||
.command("command1")
|
||||
.command("command2")
|
||||
.conclude("conclude")
|
||||
.cleanup("cleanup")
|
||||
// 1
|
||||
.expect_output("setup")
|
||||
.expect_output("prepare")
|
||||
.expect_output("command1")
|
||||
.expect_output("conclude")
|
||||
.expect_output("prepare")
|
||||
.expect_output("command1")
|
||||
.expect_output("conclude")
|
||||
.expect_output("prepare")
|
||||
.expect_output("command1")
|
||||
.expect_output("conclude")
|
||||
.expect_output("cleanup")
|
||||
// 2
|
||||
.expect_output("setup")
|
||||
.expect_output("prepare")
|
||||
.expect_output("command2")
|
||||
.expect_output("conclude")
|
||||
.expect_output("prepare")
|
||||
.expect_output("command2")
|
||||
.expect_output("conclude")
|
||||
.expect_output("prepare")
|
||||
.expect_output("command2")
|
||||
.expect_output("conclude")
|
||||
.expect_output("cleanup")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn single_parameter_value() {
|
||||
ExecutionOrderTest::new()
|
||||
|
||||
Reference in new issue
Block a user