Cleanup reporting of rng seed in existing reporters

This commit is contained in:
Martin Hořeňovský 2021-10-09 00:02:30 +02:00
parent ed1f343a41
commit 1d9696d22d
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
5 changed files with 11 additions and 18 deletions

View File

@ -520,7 +520,6 @@ 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";
currentTestRunInfo.used = true;

View File

@ -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

View File

@ -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 ) {

View File

@ -3,8 +3,8 @@
>
<testsuite name="<exe-name>" errors="17" failures="129" tests="2127" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
<property name="random-seed" value="1"/>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
</properties>
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}" status="run"/>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Catch2TestRun name="<exe-name>" filters="~[!nonportable]~[!benchmark]~[approvals] *">
<Randomness seed="1"/>
<Catch2TestRun name="<exe-name>" rng-seed="1" filters="~[!nonportable]~[!benchmark]~[approvals] *">
<TestCase name="# A test name that starts with a #" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<OverallResult success="true"/>
</TestCase>