From d41da10c549f13d5d0d0fe54300c5f1d9f2082d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 27 Oct 2022 20:43:00 +0200 Subject: [PATCH] Change reporters to report filters in round-trippable format --- src/catch2/reporters/catch_reporter_compact.cpp | 2 +- src/catch2/reporters/catch_reporter_console.cpp | 2 +- src/catch2/reporters/catch_reporter_junit.cpp | 5 +++-- src/catch2/reporters/catch_reporter_sonarqube.cpp | 2 +- src/catch2/reporters/catch_reporter_tap.cpp | 3 +-- src/catch2/reporters/catch_reporter_xml.cpp | 5 +++-- tests/CMakeLists.txt | 8 +++++++- tests/SelfTest/Baselines/compact.sw.approved.txt | 2 +- tests/SelfTest/Baselines/compact.sw.multi.approved.txt | 2 +- tests/SelfTest/Baselines/console.std.approved.txt | 2 +- tests/SelfTest/Baselines/console.sw.approved.txt | 2 +- tests/SelfTest/Baselines/console.sw.multi.approved.txt | 2 +- tests/SelfTest/Baselines/console.swa4.approved.txt | 2 +- tests/SelfTest/Baselines/junit.sw.approved.txt | 2 +- tests/SelfTest/Baselines/junit.sw.multi.approved.txt | 2 +- tests/SelfTest/Baselines/sonarqube.sw.approved.txt | 2 +- tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt | 2 +- tests/SelfTest/Baselines/tap.sw.approved.txt | 2 +- tests/SelfTest/Baselines/tap.sw.multi.approved.txt | 2 +- tests/SelfTest/Baselines/xml.sw.approved.txt | 2 +- tests/SelfTest/Baselines/xml.sw.multi.approved.txt | 2 +- 21 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/catch2/reporters/catch_reporter_compact.cpp b/src/catch2/reporters/catch_reporter_compact.cpp index ad184a1f..757dd7fc 100644 --- a/src/catch2/reporters/catch_reporter_compact.cpp +++ b/src/catch2/reporters/catch_reporter_compact.cpp @@ -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'; diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index d13be48c..7ad73995 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -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'; } diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index c24d1efa..ca8e9e32 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -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()); } } diff --git a/src/catch2/reporters/catch_reporter_sonarqube.cpp b/src/catch2/reporters/catch_reporter_sonarqube.cpp index 15b55ae0..29247ec6 100644 --- a/src/catch2/reporters/catch_reporter_sonarqube.cpp +++ b/src/catch2/reporters/catch_reporter_sonarqube.cpp @@ -23,7 +23,7 @@ namespace Catch { ReusableStringStream sstr; if ( config.testSpec().hasFilters() ) { sstr << "filters='" - << serializeFilters( config.getTestsOrTags() ) + << config.testSpec() << "' "; } sstr << "rng-seed=" << config.rngSeed(); diff --git a/src/catch2/reporters/catch_reporter_tap.cpp b/src/catch2/reporters/catch_reporter_tap.cpp index d433d986..015d972f 100644 --- a/src/catch2/reporters/catch_reporter_tap.cpp +++ b/src/catch2/reporters/catch_reporter_tap.cpp @@ -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'; } diff --git a/src/catch2/reporters/catch_reporter_xml.cpp b/src/catch2/reporters/catch_reporter_xml.cpp index 1e5def41..7f35bf37 100644 --- a/src/catch2/reporters/catch_reporter_xml.cpp +++ b/src/catch2/reporters/catch_reporter_xml.cpp @@ -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 ) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index df0a7d5d..698e40dd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -611,9 +611,15 @@ foreach (reporterName # "Automake" - the simple .trs format does not support any $ [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 ""CaseInsensitiveLess is case insensitive"") + 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}" diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index bed38433..5073c080 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -1,4 +1,4 @@ -Filters: ~[!nonportable]~[!benchmark]~[approvals] * +Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals] RNG seed: 1 Misc.tests.cpp:: passed: with 1 message: 'yay' Compilation.tests.cpp:: passed: y.v == 0 for: 0 == 0 diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index 1ba95db7..af348dda 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -1,4 +1,4 @@ -Filters: ~[!nonportable]~[!benchmark]~[approvals] * +Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals] RNG seed: 1 Misc.tests.cpp:: passed: with 1 message: 'yay' Compilation.tests.cpp:: passed: y.v == 0 for: 0 == 0 diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index b7413384..5ad8447a 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -1,4 +1,4 @@ -Filters: ~[!nonportable]~[!benchmark]~[approvals] * +Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals] Randomness seeded to: 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index 9a539685..1ef94ee5 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -1,4 +1,4 @@ -Filters: ~[!nonportable]~[!benchmark]~[approvals] * +Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals] Randomness seeded to: 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index 304baec3..c281374f 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -1,4 +1,4 @@ -Filters: ~[!nonportable]~[!benchmark]~[approvals] * +Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals] Randomness seeded to: 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/SelfTest/Baselines/console.swa4.approved.txt b/tests/SelfTest/Baselines/console.swa4.approved.txt index 1022407f..60517504 100644 --- a/tests/SelfTest/Baselines/console.swa4.approved.txt +++ b/tests/SelfTest/Baselines/console.swa4.approved.txt @@ -1,4 +1,4 @@ -Filters: ~[!nonportable]~[!benchmark]~[approvals] * +Filters: "*" ~[!nonportable] ~[!benchmark] ~[approvals] Randomness seeded to: 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index 617fc32c..bd983051 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -4,7 +4,7 @@ - + diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index 64df87e2..3231c3e8 100644 --- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -3,7 +3,7 @@ - + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index fc119949..122e3dda 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -1,5 +1,5 @@ - + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index 659080b9..8025e455 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -1,5 +1,5 @@ - + diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index c7d60903..1832282a 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -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' diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index f6e13276..4446141d 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -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' diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 2c4b5b14..0e853bfe 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -1,5 +1,5 @@ - + diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index 3f5b5c52..06be5f0c 100644 --- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -1,5 +1,5 @@ - +