From 1d9696d22d4a33b106dee1e3f69cb310d855b637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 9 Oct 2021 00:02:30 +0200 Subject: [PATCH] Cleanup reporting of rng seed in existing reporters --- src/catch2/reporters/catch_reporter_console.cpp | 3 +-- src/catch2/reporters/catch_reporter_junit.cpp | 12 +++++------- src/catch2/reporters/catch_reporter_xml.cpp | 9 +++------ tests/SelfTest/Baselines/junit.sw.approved.txt | 2 +- tests/SelfTest/Baselines/xml.sw.approved.txt | 3 +-- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index d7c2dd59..5c8b6ec7 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -520,8 +520,7 @@ void ConsoleReporter::lazyPrintRunInfo() { << " is a Catch v" << libraryVersion() << " host application.\n" << "Run with -? for options\n\n"; - if (m_config->rngSeed() != 0) - stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n"; + stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n"; currentTestRunInfo.used = true; } diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index b923aee6..8e8da3ca 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -114,19 +114,17 @@ namespace Catch { xml.writeAttribute( "time"_sr, suiteTime ); xml.writeAttribute( "timestamp"_sr, getCurrentTimestamp() ); - // Write properties if there are any - if (m_config->hasTestFilters() || m_config->rngSeed() != 0) { + // Write properties + { auto properties = xml.scopedElement("properties"); + xml.scopedElement("property") + .writeAttribute("name"_sr, "random-seed"_sr) + .writeAttribute("value"_sr, m_config->rngSeed()); if (m_config->hasTestFilters()) { xml.scopedElement("property") .writeAttribute("name"_sr, "filters"_sr) .writeAttribute("value"_sr, serializeFilters(m_config->getTestsOrTags())); } - if (m_config->rngSeed() != 0) { - xml.scopedElement("property") - .writeAttribute("name"_sr, "random-seed"_sr) - .writeAttribute("value"_sr, m_config->rngSeed()); - } } // Write test cases diff --git a/src/catch2/reporters/catch_reporter_xml.cpp b/src/catch2/reporters/catch_reporter_xml.cpp index 4e2a9a34..8c3338cb 100644 --- a/src/catch2/reporters/catch_reporter_xml.cpp +++ b/src/catch2/reporters/catch_reporter_xml.cpp @@ -51,14 +51,11 @@ namespace Catch { std::string stylesheetRef = getStylesheetRef(); if( !stylesheetRef.empty() ) m_xml.writeStylesheetRef( stylesheetRef ); - m_xml.startElement( "Catch2TestRun" ); - if( !m_config->name().empty() ) - m_xml.writeAttribute( "name"_sr, m_config->name() ); + m_xml.startElement("Catch2TestRun") + .writeAttribute("name"_sr, m_config->name()) + .writeAttribute("rng-seed"_sr, m_config->rngSeed()); if (m_config->testSpec().hasFilters()) m_xml.writeAttribute( "filters"_sr, serializeFilters( m_config->getTestsOrTags() ) ); - if( m_config->rngSeed() != 0 ) - m_xml.scopedElement( "Randomness" ) - .writeAttribute( "seed"_sr, m_config->rngSeed() ); } void XmlReporter::testCaseStarting( TestCaseInfo const& testInfo ) { diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index 26afed94..d99f25e8 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -3,8 +3,8 @@ > - + diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 13544d49..2fee44e4 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -1,6 +1,5 @@ - - +