From 7e7ab0e28b23121e4f02de19080127a9363309d1 Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Mon, 29 Jul 2019 12:42:49 +0200 Subject: [PATCH] Fix xml reporter crashing when a benchmark failed. --- 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(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;