Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Fix xml reporter crashing when a benchmark failed.

Commit
7e7ab0e28b23121e4f02de19080127a9363309d1
Author
Joachim Meyer ·
Committer
Martin Hořeňovský
Parents
425957dc63a6

Files · Download .tar.gz

Changes

 include/reporters/catch_reporter_xml.cpp | 9 ++++++---
 include/reporters/catch_reporter_xml.h   | 1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/reporters/catch_reporter_xml.cpp b/include/reporters/catch_reporter_xml.cpp
index f626fb68..26ca8918 100644
--- a/include/reporters/catch_reporter_xml.cpp
+++ b/include/reporters/catch_reporter_xml.cpp
@@ -220,10 +220,13 @@ namespace Catch {
     }
 
 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
-    void XmlReporter::benchmarkStarting(BenchmarkInfo const &info) {
+    void XmlReporter::benchmarkPreparing(std::string const& name) {
         m_xml.startElement("BenchmarkResults")
-            .writeAttribute("name", info.name)
-            .writeAttribute("samples", info.samples)
+            .writeAttribute("name", name);
+    }
+
+    void XmlReporter::benchmarkStarting(BenchmarkInfo const &info) {
+        m_xml.writeAttribute("samples", info.samples)
             .writeAttribute("resamples", info.resamples)
             .writeAttribute("iterations", info.iterations)
             .writeAttribute("clockResolution", static_cast<uint64_t>(info.clockResolution))
diff --git a/include/reporters/catch_reporter_xml.h b/include/reporters/catch_reporter_xml.h
index 761f98f1..5b6ba310 100644
--- a/include/reporters/catch_reporter_xml.h
+++ b/include/reporters/catch_reporter_xml.h
@@ -51,6 +51,7 @@ namespace Catch {
         void testRunEnded(TestRunStats const& testRunStats) override;
 
 #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
+        void benchmarkPreparing(std::string const& name) override;
         void benchmarkStarting(BenchmarkInfo const&) override;
         void benchmarkEnded(BenchmarkStats<> const&) override;
         void benchmarkFailed(std::string const&) override;