mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 04:07:10 +01:00 
			
		
		
		
	Fix inconsistencies in reporting benchmarking failures
With these changes, all these benchmarks
```cpp
BENCHMARK("Empty benchmark") {};
BENCHMARK("Throwing benchmark") {
    throw "just a plain literal, bleh";
};
BENCHMARK("Asserting benchmark") {
    REQUIRE(1 == 2);
};
BENCHMARK("FAIL'd benchmark") {
    FAIL("This benchmark only fails, nothing else");
};
```
report the respective failure and mark the outer `TEST_CASE` as
failed. Previously, the first two would not fail the `TEST_CASE`,
and the latter two would break xml reporter's formatting, because
`benchmarkFailed`, `benchmarkEnded` etc would not be be called
properly in failure cases.
			
			
This commit is contained in:
		| @@ -412,3 +412,24 @@ TEST_CASE("run benchmark", "[benchmark][approvals]") { | ||||
|  | ||||
|     CHECK((end - start).count() == 2867251000); | ||||
| } | ||||
|  | ||||
| TEST_CASE("Failing benchmarks", "[!benchmark][.approvals]") { | ||||
|     SECTION("empty", "Benchmark that has been optimized away (because it is empty)") { | ||||
|         BENCHMARK("Empty benchmark") {}; | ||||
|     } | ||||
|     SECTION("throw", "Benchmark that throws an exception") { | ||||
|         BENCHMARK("Throwing benchmark") { | ||||
|             throw "just a plain literal, bleh"; | ||||
|         }; | ||||
|     } | ||||
|     SECTION("assert", "Benchmark that asserts inside") { | ||||
|         BENCHMARK("Asserting benchmark") { | ||||
|             REQUIRE(1 == 2); | ||||
|         }; | ||||
|     } | ||||
|     SECTION("fail", "Benchmark that fails inside") { | ||||
|         BENCHMARK("FAIL'd benchmark") { | ||||
|             FAIL("This benchmark only fails, nothing else"); | ||||
|         }; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský