Change reporters to report filters in round-trippable format

This commit is contained in:
Martin Hořeňovský 2022-10-27 20:43:00 +02:00
parent d2294ad9b6
commit d41da10c54
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
21 changed files with 31 additions and 24 deletions

View File

@ -207,7 +207,7 @@ private:
if ( m_config->testSpec().hasFilters() ) {
m_stream << m_colour->guardColour( Colour::BrightYellow )
<< "Filters: "
<< serializeFilters( m_config->getTestsOrTags() )
<< m_config->testSpec()
<< '\n';
}
m_stream << "RNG seed: " << getSeed() << '\n';

View File

@ -499,7 +499,7 @@ void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) {
StreamingReporterBase::testRunStarting(_testInfo);
if ( m_config->testSpec().hasFilters() ) {
m_stream << m_colour->guardColour( Colour::BrightYellow ) << "Filters: "
<< serializeFilters( m_config->getTestsOrTags() ) << '\n';
<< m_config->testSpec() << '\n';
}
m_stream << "Randomness seeded to: " << getSeed() << '\n';
}

View File

@ -13,6 +13,7 @@
#include <catch2/internal/catch_textflow.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/catch_test_case_info.hpp>
#include <catch2/catch_test_spec.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <cassert>
@ -143,10 +144,10 @@ namespace Catch {
xml.scopedElement("property")
.writeAttribute("name"_sr, "random-seed"_sr)
.writeAttribute("value"_sr, m_config->rngSeed());
if (m_config->hasTestFilters()) {
if (m_config->testSpec().hasFilters()) {
xml.scopedElement("property")
.writeAttribute("name"_sr, "filters"_sr)
.writeAttribute("value"_sr, serializeFilters(m_config->getTestsOrTags()));
.writeAttribute("value"_sr, m_config->testSpec());
}
}

View File

@ -23,7 +23,7 @@ namespace Catch {
ReusableStringStream sstr;
if ( config.testSpec().hasFilters() ) {
sstr << "filters='"
<< serializeFilters( config.getTestsOrTags() )
<< config.testSpec()
<< "' ";
}
sstr << "rng-seed=" << config.rngSeed();

View File

@ -189,8 +189,7 @@ namespace Catch {
void TAPReporter::testRunStarting( TestRunInfo const& ) {
if ( m_config->testSpec().hasFilters() ) {
m_stream << "# filters: "
<< serializeFilters( m_config->getTestsOrTags() ) << '\n';
m_stream << "# filters: " << m_config->testSpec() << '\n';
}
m_stream << "# rng-seed: " << m_config->rngSeed() << '\n';
}

View File

@ -57,8 +57,9 @@ namespace Catch {
.writeAttribute("name"_sr, m_config->name())
.writeAttribute("rng-seed"_sr, m_config->rngSeed())
.writeAttribute("catch2-version"_sr, libraryVersion());
if (m_config->testSpec().hasFilters())
m_xml.writeAttribute( "filters"_sr, serializeFilters( m_config->getTestsOrTags() ) );
if ( m_config->testSpec().hasFilters() ) {
m_xml.writeAttribute( "filters"_sr, m_config->testSpec() );
}
}
void XmlReporter::testCaseStarting( TestCaseInfo const& testInfo ) {

View File

@ -611,9 +611,15 @@ foreach (reporterName # "Automake" - the simple .trs format does not support any
$<TARGET_FILE:SelfTest> [comparisons][string-case] "CaseInsensitiveLess is case insensitive"
--reporter ${reporterName}
)
# Different regex for these two reporters, because the commas end up xml-escaped
if (reporterName MATCHES "JUnit|XML")
set(testCaseNameFormat "&quot;CaseInsensitiveLess is case insensitive&quot;")
else()
set(testCaseNameFormat "\"CaseInsensitiveLess is case insensitive\"")
endif()
set_tests_properties("Reporters:Filters:${reporterName}"
PROPERTIES
PASS_REGULAR_EXPRESSION "[fF]ilters.+\\[comparisons\\]\\[string-case\\]"
PASS_REGULAR_EXPRESSION "[fF]ilters.+\\[comparisons\\] \\[string-case\\] ${testCaseNameFormat}"
)
add_test(NAME "Reporters:RngSeed:${reporterName}"

View File

@ -1,4 +1,4 @@
Filters: ~[!nonportable]~[!benchmark]~[approvals] *
Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals]
RNG seed: 1
Misc.tests.cpp:<line number>: passed: with 1 message: 'yay'
Compilation.tests.cpp:<line number>: passed: y.v == 0 for: 0 == 0

View File

@ -1,4 +1,4 @@
Filters: ~[!nonportable]~[!benchmark]~[approvals] *
Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals]
RNG seed: 1
Misc.tests.cpp:<line number>: passed: with 1 message: 'yay'
Compilation.tests.cpp:<line number>: passed: y.v == 0 for: 0 == 0

View File

@ -1,4 +1,4 @@
Filters: ~[!nonportable]~[!benchmark]~[approvals] *
Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals]
Randomness seeded to: 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,4 +1,4 @@
Filters: ~[!nonportable]~[!benchmark]~[approvals] *
Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals]
Randomness seeded to: 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,4 +1,4 @@
Filters: ~[!nonportable]~[!benchmark]~[approvals] *
Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals]
Randomness seeded to: 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,4 +1,4 @@
Filters: ~[!nonportable]~[!benchmark]~[approvals] *
Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals]
Randomness seeded to: 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -4,7 +4,7 @@
<testsuite name="<exe-name>" errors="17" failures="126" tests="2159" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
<property name="filters" value="&quot;*&quot; ~[!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="#1027: Bitfields can be captured" time="{duration}" status="run"/>

View File

@ -3,7 +3,7 @@
<testsuite name="<exe-name>" errors="17" failures="126" tests="2159" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
<property name="filters" value="&quot;*&quot; ~[!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="#1027: Bitfields can be captured" time="{duration}" status="run"/>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- filters='~[!nonportable]~[!benchmark]~[approvals] *' rng-seed=1 -->
<!-- filters='"*" ~[!nonportable] ~[!benchmark] ~[approvals]' rng-seed=1 -->
<testExecutions version="1"loose text artifact
>
<file path="tests/<exe-name>/IntrospectiveTests/Clara.tests.cpp">

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- filters='~[!nonportable]~[!benchmark]~[approvals] *' rng-seed=1 -->
<!-- filters='"*" ~[!nonportable] ~[!benchmark] ~[approvals]' rng-seed=1 -->
<testExecutions version="1">
<file path="tests/<exe-name>/IntrospectiveTests/Clara.tests.cpp">
<testCase name="Clara::Arg supports single-arg parse the way Opt does" duration="{duration}"/>

View File

@ -1,4 +1,4 @@
# filters: ~[!nonportable]~[!benchmark]~[approvals] *
# filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals]
# rng-seed: 1
# # A test name that starts with a #
ok {test-number} - with 1 message: 'yay'

View File

@ -1,4 +1,4 @@
# filters: ~[!nonportable]~[!benchmark]~[approvals] *
# filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals]
# rng-seed: 1
# # A test name that starts with a #
ok {test-number} - with 1 message: 'yay'

View File

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

View File

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