|
1 | 1 | use assert_cmd::assert::OutputAssertExt;
|
| 2 | +use predicates::prelude::*; |
2 | 3 | use predicates::str::contains;
|
3 | 4 |
|
4 | 5 | mod helpers;
|
@@ -82,3 +83,78 @@ fn test_simple_cargo_bench_no_run() {
|
82 | 83 | .success();
|
83 | 84 | teardown(dir);
|
84 | 85 | }
|
| 86 | + |
| 87 | +#[test] |
| 88 | +fn test_simple_run_without_details() { |
| 89 | + let dir = setup(DIR, Project::Simple); |
| 90 | + cargo_codspeed(&dir).arg("build").assert().success(); |
| 91 | + cargo_codspeed(&dir) |
| 92 | + .arg("run") |
| 93 | + .assert() |
| 94 | + .success() |
| 95 | + .stderr(contains("Finished running 2 benchmark suite(s)")) |
| 96 | + .stderr(predicates::str::contains("benchmarks total").not()) |
| 97 | + .stdout( |
| 98 | + predicates::str::is_match(r" Checked: .* \([0-9]+(\.[0-9]+)? (ns|us|ms|s)\)") |
| 99 | + .unwrap() |
| 100 | + .not(), |
| 101 | + ); |
| 102 | + teardown(dir); |
| 103 | +} |
| 104 | + |
| 105 | +#[test] |
| 106 | +fn test_simple_run_with_details() { |
| 107 | + let dir = setup(DIR, Project::Simple); |
| 108 | + cargo_codspeed(&dir).arg("build").assert().success(); |
| 109 | + cargo_codspeed(&dir) |
| 110 | + .arg("run") |
| 111 | + .arg("--details") |
| 112 | + .assert() |
| 113 | + .success() |
| 114 | + .stderr(contains("benchmarks total")) |
| 115 | + .stderr(contains("Done running")) |
| 116 | + .stdout( |
| 117 | + predicates::str::is_match(r" Checked: .* \([0-9]+(\.[0-9]+)? (ns|us|ms|s)\)").unwrap(), |
| 118 | + ); |
| 119 | + teardown(dir); |
| 120 | +} |
| 121 | + |
| 122 | +#[test] |
| 123 | +fn test_benchmark_counting_with_details() { |
| 124 | + let dir = setup(DIR, Project::Simple); |
| 125 | + cargo_codspeed(&dir).arg("build").assert().success(); |
| 126 | + cargo_codspeed(&dir) |
| 127 | + .arg("run") |
| 128 | + .arg("--details") |
| 129 | + .assert() |
| 130 | + .success() |
| 131 | + .stderr(contains("Done running bencher_example (2 benchmarks)")) |
| 132 | + .stderr(contains( |
| 133 | + "Done running another_bencher_example (2 benchmarks)", |
| 134 | + )) |
| 135 | + .stderr(contains( |
| 136 | + "Finished running 2 benchmark suite(s) (4 benchmarks total)", |
| 137 | + )); |
| 138 | + teardown(dir); |
| 139 | +} |
| 140 | + |
| 141 | +#[test] |
| 142 | +fn test_single_benchmark_counting_with_details() { |
| 143 | + let dir = setup(DIR, Project::Simple); |
| 144 | + cargo_codspeed(&dir) |
| 145 | + .arg("build") |
| 146 | + .args(["--bench", "bencher_example"]) |
| 147 | + .assert() |
| 148 | + .success(); |
| 149 | + cargo_codspeed(&dir) |
| 150 | + .arg("run") |
| 151 | + .arg("--details") |
| 152 | + .args(["--bench", "bencher_example"]) |
| 153 | + .assert() |
| 154 | + .success() |
| 155 | + .stderr(contains("Done running bencher_example (2 benchmarks)")) |
| 156 | + .stderr(contains( |
| 157 | + "Finished running 1 benchmark suite(s) (2 benchmarks total)", |
| 158 | + )); |
| 159 | + teardown(dir); |
| 160 | +} |
0 commit comments