Expand execution order tests

This commit is contained in:
David Peter 2022-02-06 22:49:41 +01:00
parent aae3a4116f
commit 5df981ae7b
2 changed files with 52 additions and 11 deletions

View File

@ -76,7 +76,7 @@ fn build_app() -> App<'static> {
.help(
"Execute CMD before each set of timing runs. This is useful for \
compiling your software with the provided parameters, or to do any \
other work that should happen once before a series of benchmark runs,\
other work that should happen once before a series of benchmark runs, \
not every time as would happen with the --prepare option."
),
)

View File

@ -160,6 +160,33 @@ fn prepare_commands_are_executed_before_each_timing_run() {
.run();
}
#[test]
fn prepare_commands_are_executed_before_each_warmup() {
ExecutionOrderTest::new()
.arg("--warmup=2")
.arg("--runs=1")
.prepare("prepare")
.command("command 1")
.command("command 2")
// warmup 1
.expect_output("prepare")
.expect_output("command 1")
.expect_output("prepare")
.expect_output("command 1")
// benchmark 1
.expect_output("prepare")
.expect_output("command 1")
// warmup 2
.expect_output("prepare")
.expect_output("command 2")
.expect_output("prepare")
.expect_output("command 2")
// benchmark 2
.expect_output("prepare")
.expect_output("command 2")
.run();
}
#[test]
fn cleanup_commands_are_executed_once_after_each_benchmark() {
ExecutionOrderTest::new()
@ -179,17 +206,31 @@ fn cleanup_commands_are_executed_once_after_each_benchmark() {
#[test]
fn setup_prepare_cleanup_combined() {
ExecutionOrderTest::new()
.arg("--warmup=1")
.arg("--runs=2")
.setup("make")
.prepare("make testclean")
.command("make test")
.cleanup("make clean")
.expect_output("make")
.expect_output("make testclean")
.expect_output("make test")
.expect_output("make testclean")
.expect_output("make test")
.expect_output("make clean")
.setup("setup")
.prepare("prepare")
.command("command1")
.command("command2")
.cleanup("cleanup")
// 1
.expect_output("setup")
.expect_output("prepare")
.expect_output("command1")
.expect_output("prepare")
.expect_output("command1")
.expect_output("prepare")
.expect_output("command1")
.expect_output("cleanup")
// 2
.expect_output("setup")
.expect_output("prepare")
.expect_output("command2")
.expect_output("prepare")
.expect_output("command2")
.expect_output("prepare")
.expect_output("command2")
.expect_output("cleanup")
.run();
}