diff --git a/docs/filtering-execution-path.md b/docs/filtering-execution-path.md index fad02624a6..07dd8252b1 100644 --- a/docs/filtering-execution-path.md +++ b/docs/filtering-execution-path.md @@ -19,6 +19,22 @@ behaviour, which does not affect generators at all. If you also use either `-g`/`--generator-index`, or `-p`/`--path-filter`, you will get the new behaviour, which can also filter generator elements. +When path filters are in effect, the console and compact reporters print +the active selection at the start of the run, next to the `Filters:` line, +e.g. + +```text +Filters: "foo" +Path filters: + - Section: "A" + - Generator: "0" +``` + +The filters are listed one per line, labelled as `Section` or `Generator`, +in the order in which they were specified. This makes it easy to see exactly +what has been selected when a filter combination ends up running no +assertions. + Both the new and old filter behaviours include some potentially surprising things: * Code outside of sections being skipped will still be executed. E.g. diff --git a/src/catch2/reporters/catch_reporter_compact.cpp b/src/catch2/reporters/catch_reporter_compact.cpp index 6d2c86552a..56e4c760de 100644 --- a/src/catch2/reporters/catch_reporter_compact.cpp +++ b/src/catch2/reporters/catch_reporter_compact.cpp @@ -215,6 +215,12 @@ class AssertionPrinter { << m_config->testSpec() << '\n'; } + if ( !m_config->getPathFilters().empty() ) { + m_stream << m_colour->guardColour( Colour::BrightYellow ) + << "Path filters:\n" + << serializePathFilters( m_config->getPathFilters() ) + << '\n'; + } m_stream << "RNG seed: " << getSeed() << '\n' << std::flush; } diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index acb4ae8e72..c9d11c8e2a 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -530,6 +530,11 @@ void ConsoleReporter::testRunStarting(TestRunInfo const& _testRunInfo) { m_stream << m_colour->guardColour( Colour::BrightYellow ) << "Filters: " << m_config->testSpec() << '\n'; } + if ( !m_config->getPathFilters().empty() ) { + m_stream << m_colour->guardColour( Colour::BrightYellow ) + << "Path filters:\n" + << serializePathFilters( m_config->getPathFilters() ) << '\n'; + } m_stream << "Randomness seeded to: " << getSeed() << '\n' << std::flush; } diff --git a/src/catch2/reporters/catch_reporter_helpers.cpp b/src/catch2/reporters/catch_reporter_helpers.cpp index 0044efb5de..e5b2cee5a7 100644 --- a/src/catch2/reporters/catch_reporter_helpers.cpp +++ b/src/catch2/reporters/catch_reporter_helpers.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -101,6 +102,28 @@ namespace Catch { return serialized; } + std::string serializePathFilters( std::vector const& filters ) { + ReusableStringStream rss; + bool first = true; + for ( auto const& filter : filters ) { + if ( !first ) { + rss << '\n'; + } + first = false; + rss << " - "; + switch ( filter.type ) { + case PathFilter::For::Section: + rss << "Section: "; + break; + case PathFilter::For::Generator: + rss << "Generator: "; + break; + } + rss << '"' << filter.filter << '"'; + } + return rss.str(); + } + std::ostream& operator<<( std::ostream& out, lineOfChars value ) { for ( size_t idx = 0; idx < CATCH_CONFIG_CONSOLE_WIDTH - 1; ++idx ) { out.put( value.c ); diff --git a/src/catch2/reporters/catch_reporter_helpers.hpp b/src/catch2/reporters/catch_reporter_helpers.hpp index 469888884a..bd2ebbc85e 100644 --- a/src/catch2/reporters/catch_reporter_helpers.hpp +++ b/src/catch2/reporters/catch_reporter_helpers.hpp @@ -21,6 +21,7 @@ namespace Catch { class IConfig; class TestCaseHandle; class ColourImpl; + struct PathFilter; // Returns double formatted as %.3f (format expected on output) std::string getFormattedDuration( double duration ); @@ -30,6 +31,18 @@ namespace Catch { std::string serializeFilters( std::vector const& filters ); + /** + * Serializes the active section/generator path filters into a + * human-readable, indented list, one filter per line and in the order + * in which they were specified, e.g. + * + * - Section: "A" + * - Generator: "0" + * + * The returned string has no trailing newline. + */ + std::string serializePathFilters( std::vector const& filters ); + struct lineOfChars { char c; constexpr lineOfChars( char c_ ): c( c_ ) {} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7429734f8c..c8bbb44208 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -666,6 +666,33 @@ foreach(reporterName # "Automake" - the simple .trs format does not support any ) endforeach() +# The console and compact reporters print the active section/generator +# selection (path filters), so that it is obvious what has been selected. +# The exact serialization is unit-tested in `serializePathFilters ...`, so +# here we only check that both reporters actually emit the line, using a +# section filter for one and a generator filter for the other. +add_test(NAME "Reporters:PathFilters:Section:compact" + COMMAND + $ "Tracker" + --reporter compact + --section "section name" +) +set_tests_properties("Reporters:PathFilters:Section:compact" + PROPERTIES + PASS_REGULAR_EXPRESSION "- Section: \"section name\"" +) + +add_test(NAME "Reporters:PathFilters:Generator:console" + COMMAND + $ "Generators internals" + --reporter console + --generator-index 0 +) +set_tests_properties("Reporters:PathFilters:Generator:console" + PROPERTIES + PASS_REGULAR_EXPRESSION "- Generator: \"0\"" +) + add_test(NAME "Bazel::RngSeedEnvVar::JustEnv" COMMAND $ "Factorials are computed" diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index 5018a19ad2..ef0b88f60d 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -409,6 +409,7 @@ b1! :test-result: SKIP sections can be skipped dynamically at runtime :test-result: FAIL send a single char to INFO :test-result: FAIL sends information to INFO +:test-result: PASS serializePathFilters serializes the section/generator selection :test-result: PASS shortened hide tags are split apart :test-result: SKIP skipped tests can optionally provide a reason :test-result: PASS splitString diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt index 4f9a94410d..8b7c28cbd6 100644 --- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt @@ -398,6 +398,7 @@ :test-result: SKIP sections can be skipped dynamically at runtime :test-result: FAIL send a single char to INFO :test-result: FAIL sends information to INFO +:test-result: PASS serializePathFilters serializes the section/generator selection :test-result: PASS shortened hide tags are split apart :test-result: SKIP skipped tests can optionally provide a reason :test-result: PASS splitString diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index cb90a0f559..b8756f9203 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -2831,6 +2831,20 @@ Skip.tests.cpp:: skipped: Skip.tests.cpp:: passed: Misc.tests.cpp:: failed: false with 1 message: '3' Message.tests.cpp:: failed: false with 2 messages: 'hi' and 'i := 7' +Reporters.tests.cpp:: passed: serializePathFilters( {} ).empty() for: true +Reporters.tests.cpp:: passed: serializePathFilters( filters ) == " - Section: \"a section\"" for: " - Section: "a section"" +== +" - Section: "a section"" +Reporters.tests.cpp:: passed: serializePathFilters( filters ) == " - Generator: \"0\"" for: " - Generator: "0"" +== +" - Generator: "0"" +Reporters.tests.cpp:: passed: serializePathFilters( filters ) == " - Section: \"A\"\n" " - Generator: \"1\"\n" " - Section: \"B\"" for: " - Section: "A" + - Generator: "1" + - Section: "B"" +== +" - Section: "A" + - Generator: "1" + - Section: "B"" Tag.tests.cpp:: passed: testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) Skip.tests.cpp:: skipped: 'skipping because answer = 43' StringManip.tests.cpp:: passed: splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } @@ -3000,7 +3014,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 451 | 331 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2416 | 2215 passed | 158 failed | 43 failed as expected +test cases: 452 | 332 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2420 | 2219 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index 39c260afd4..d5f4cb5f11 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -2820,6 +2820,20 @@ Skip.tests.cpp:: skipped: Skip.tests.cpp:: passed: Misc.tests.cpp:: failed: false with 1 message: '3' Message.tests.cpp:: failed: false with 2 messages: 'hi' and 'i := 7' +Reporters.tests.cpp:: passed: serializePathFilters( {} ).empty() for: true +Reporters.tests.cpp:: passed: serializePathFilters( filters ) == " - Section: \"a section\"" for: " - Section: "a section"" +== +" - Section: "a section"" +Reporters.tests.cpp:: passed: serializePathFilters( filters ) == " - Generator: \"0\"" for: " - Generator: "0"" +== +" - Generator: "0"" +Reporters.tests.cpp:: passed: serializePathFilters( filters ) == " - Section: \"A\"\n" " - Generator: \"1\"\n" " - Section: \"B\"" for: " - Section: "A" + - Generator: "1" + - Section: "B"" +== +" - Section: "A" + - Generator: "1" + - Section: "B"" Tag.tests.cpp:: passed: testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) Skip.tests.cpp:: skipped: 'skipping because answer = 43' StringManip.tests.cpp:: passed: splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } @@ -2989,7 +3003,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 451 | 331 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2416 | 2215 passed | 158 failed | 43 failed as expected +test cases: 452 | 332 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2420 | 2219 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index 78c3d64051..134556ded1 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -1743,6 +1743,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 451 | 349 passed | 76 failed | 7 skipped | 19 failed as expected -assertions: 2394 | 2215 passed | 136 failed | 43 failed as expected +test cases: 452 | 350 passed | 76 failed | 7 skipped | 19 failed as expected +assertions: 2398 | 2219 passed | 136 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index add1eaaf51..2ccf3795aa 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -18942,6 +18942,64 @@ with messages: hi i := 7 +------------------------------------------------------------------------------- +serializePathFilters serializes the section/generator selection + No filters serialize to an empty string +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE( serializePathFilters( {} ).empty() ) +with expansion: + true + +------------------------------------------------------------------------------- +serializePathFilters serializes the section/generator selection + Section filters are labelled and quoted +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE( serializePathFilters( filters ) == " - Section: \"a section\"" ) +with expansion: + " - Section: "a section"" + == + " - Section: "a section"" + +------------------------------------------------------------------------------- +serializePathFilters serializes the section/generator selection + Generator filters are labelled and quoted +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE( serializePathFilters( filters ) == " - Generator: \"0\"" ) +with expansion: + " - Generator: "0"" + == + " - Generator: "0"" + +------------------------------------------------------------------------------- +serializePathFilters serializes the section/generator selection + Multiple filters keep their order, one per line +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE( serializePathFilters( filters ) == " - Section: \"A\"\n" " - Generator: \"1\"\n" " - Section: \"B\"" ) +with expansion: + " - Section: "A" + - Generator: "1" + - Section: "B"" + == + " - Section: "A" + - Generator: "1" + - Section: "B"" + ------------------------------------------------------------------------------- shortened hide tags are split apart ------------------------------------------------------------------------------- @@ -20134,6 +20192,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 451 | 331 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2416 | 2215 passed | 158 failed | 43 failed as expected +test cases: 452 | 332 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2420 | 2219 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index 071955777d..81f2c4e287 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -18931,6 +18931,64 @@ with messages: hi i := 7 +------------------------------------------------------------------------------- +serializePathFilters serializes the section/generator selection + No filters serialize to an empty string +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE( serializePathFilters( {} ).empty() ) +with expansion: + true + +------------------------------------------------------------------------------- +serializePathFilters serializes the section/generator selection + Section filters are labelled and quoted +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE( serializePathFilters( filters ) == " - Section: \"a section\"" ) +with expansion: + " - Section: "a section"" + == + " - Section: "a section"" + +------------------------------------------------------------------------------- +serializePathFilters serializes the section/generator selection + Generator filters are labelled and quoted +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE( serializePathFilters( filters ) == " - Generator: \"0\"" ) +with expansion: + " - Generator: "0"" + == + " - Generator: "0"" + +------------------------------------------------------------------------------- +serializePathFilters serializes the section/generator selection + Multiple filters keep their order, one per line +------------------------------------------------------------------------------- +Reporters.tests.cpp: +............................................................................... + +Reporters.tests.cpp:: PASSED: + REQUIRE( serializePathFilters( filters ) == " - Section: \"A\"\n" " - Generator: \"1\"\n" " - Section: \"B\"" ) +with expansion: + " - Section: "A" + - Generator: "1" + - Section: "B"" + == + " - Section: "A" + - Generator: "1" + - Section: "B"" + ------------------------------------------------------------------------------- shortened hide tags are split apart ------------------------------------------------------------------------------- @@ -20123,6 +20181,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 451 | 331 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2416 | 2215 passed | 158 failed | 43 failed as expected +test cases: 452 | 332 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2420 | 2219 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index 328b466c0e..6648e87443 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -1817,6 +1817,11 @@ i := 7 at Message.tests.cpp: + + + + + diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index 403ed251b7..cb953e7968 100644 --- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -1,6 +1,6 @@ - + @@ -1816,6 +1816,11 @@ i := 7 at Message.tests.cpp: + + + + + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index f9e851fc14..19048de16f 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -339,6 +339,11 @@ at AssertionHandler.tests.cpp: + + + + + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index e1ede12c12..aa26f0fea2 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -338,6 +338,11 @@ at AssertionHandler.tests.cpp: + + + + + diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index 7624d1406e..00978c9b0d 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -4585,6 +4585,14 @@ ok {test-number} - not ok {test-number} - false with 1 message: '3' # sends information to INFO not ok {test-number} - false with 2 messages: 'hi' and 'i := 7' +# serializePathFilters serializes the section/generator selection +ok {test-number} - serializePathFilters( {} ).empty() for: true +# serializePathFilters serializes the section/generator selection +ok {test-number} - serializePathFilters( filters ) == " - Section: \"a section\"" for: " - Section: "a section"" == " - Section: "a section"" +# serializePathFilters serializes the section/generator selection +ok {test-number} - serializePathFilters( filters ) == " - Generator: \"0\"" for: " - Generator: "0"" == " - Generator: "0"" +# serializePathFilters serializes the section/generator selection +ok {test-number} - serializePathFilters( filters ) == " - Section: \"A\"\n" " - Generator: \"1\"\n" " - Section: \"B\"" for: " - Section: "A" - Generator: "1" - Section: "B"" == " - Section: "A" - Generator: "1" - Section: "B"" # shortened hide tags are split apart ok {test-number} - testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) # skipped tests can optionally provide a reason @@ -4851,5 +4859,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2428 +1..2432 diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index ed653421b1..6a5a5ef26a 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -4574,6 +4574,14 @@ ok {test-number} - not ok {test-number} - false with 1 message: '3' # sends information to INFO not ok {test-number} - false with 2 messages: 'hi' and 'i := 7' +# serializePathFilters serializes the section/generator selection +ok {test-number} - serializePathFilters( {} ).empty() for: true +# serializePathFilters serializes the section/generator selection +ok {test-number} - serializePathFilters( filters ) == " - Section: \"a section\"" for: " - Section: "a section"" == " - Section: "a section"" +# serializePathFilters serializes the section/generator selection +ok {test-number} - serializePathFilters( filters ) == " - Generator: \"0\"" for: " - Generator: "0"" == " - Generator: "0"" +# serializePathFilters serializes the section/generator selection +ok {test-number} - serializePathFilters( filters ) == " - Section: \"A\"\n" " - Generator: \"1\"\n" " - Section: \"B\"" for: " - Section: "A" - Generator: "1" - Section: "B"" == " - Section: "A" - Generator: "1" - Section: "B"" # shortened hide tags are split apart ok {test-number} - testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) # skipped tests can optionally provide a reason @@ -4840,5 +4848,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2428 +1..2432 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index bbd587ff49..912c057c58 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -992,6 +992,8 @@ loose text artifact ##teamcity[testStarted name='sends information to INFO'] ##teamcity[testFailed name='sends information to INFO' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with messages:|n "hi"|n "i := 7"|n REQUIRE( false )|nwith expansion:|n false|n'] ##teamcity[testFinished name='sends information to INFO' duration="{duration}"] +##teamcity[testStarted name='serializePathFilters serializes the section/generator selection'] +##teamcity[testFinished name='serializePathFilters serializes the section/generator selection' duration="{duration}"] ##teamcity[testStarted name='shortened hide tags are split apart'] ##teamcity[testFinished name='shortened hide tags are split apart' duration="{duration}"] ##teamcity[testStarted name='skipped tests can optionally provide a reason'] diff --git a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt index fb73387f89..0f06d85fae 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt @@ -991,6 +991,8 @@ ##teamcity[testStarted name='sends information to INFO'] ##teamcity[testFailed name='sends information to INFO' message='Message.tests.cpp:|n...............................................................................|n|nMessage.tests.cpp:|nexpression failed with messages:|n "hi"|n "i := 7"|n REQUIRE( false )|nwith expansion:|n false|n'] ##teamcity[testFinished name='sends information to INFO' duration="{duration}"] +##teamcity[testStarted name='serializePathFilters serializes the section/generator selection'] +##teamcity[testFinished name='serializePathFilters serializes the section/generator selection' duration="{duration}"] ##teamcity[testStarted name='shortened hide tags are split apart'] ##teamcity[testFinished name='shortened hide tags are split apart' duration="{duration}"] ##teamcity[testStarted name='skipped tests can optionally provide a reason'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 933094d34c..3663dffbbd 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -22075,6 +22075,63 @@ Approx( -1.95996398454005449 ) + +
+ + + serializePathFilters( {} ).empty() + + + true + + + +
+
+ + + serializePathFilters( filters ) == " - Section: \"a section\"" + + + " - Section: "a section"" +== +" - Section: "a section"" + + + +
+
+ + + serializePathFilters( filters ) == " - Generator: \"0\"" + + + " - Generator: "0"" +== +" - Generator: "0"" + + + +
+
+ + + serializePathFilters( filters ) == " - Section: \"A\"\n" " - Generator: \"1\"\n" " - Section: \"B\"" + + + " - Section: "A" + - Generator: "1" + - Section: "B"" +== +" - Section: "A" + - Generator: "1" + - Section: "B"" + + + +
+ +
@@ -23385,6 +23442,6 @@ Approx( -1.95996398454005449 ) - - + + diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index 646f0c72f9..8bb5857276 100644 --- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -22074,6 +22074,63 @@ Approx( -1.95996398454005449 )
+ +
+ + + serializePathFilters( {} ).empty() + + + true + + + +
+
+ + + serializePathFilters( filters ) == " - Section: \"a section\"" + + + " - Section: "a section"" +== +" - Section: "a section"" + + + +
+
+ + + serializePathFilters( filters ) == " - Generator: \"0\"" + + + " - Generator: "0"" +== +" - Generator: "0"" + + + +
+
+ + + serializePathFilters( filters ) == " - Section: \"A\"\n" " - Generator: \"1\"\n" " - Section: \"B\"" + + + " - Section: "A" + - Generator: "1" + - Section: "B"" +== +" - Section: "A" + - Generator: "1" + - Section: "B"" + + + +
+ +
@@ -23384,6 +23441,6 @@ Approx( -1.95996398454005449 ) - - + + diff --git a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp index afb5143ada..ece4fc4cf4 100644 --- a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -96,6 +97,35 @@ TEST_CASE( "The default listing implementation write to provided stream", } } +TEST_CASE( "serializePathFilters serializes the section/generator selection", + "[reporters][reporter-helpers]" ) { + using Catch::PathFilter; + using Catch::serializePathFilters; + + SECTION( "No filters serialize to an empty string" ) { + REQUIRE( serializePathFilters( {} ).empty() ); + } + SECTION( "Section filters are labelled and quoted" ) { + std::vector filters{ { PathFilter::For::Section, "a section" } }; + REQUIRE( serializePathFilters( filters ) == " - Section: \"a section\"" ); + } + SECTION( "Generator filters are labelled and quoted" ) { + std::vector filters{ { PathFilter::For::Generator, "0" } }; + REQUIRE( serializePathFilters( filters ) == " - Generator: \"0\"" ); + } + SECTION( "Multiple filters keep their order, one per line" ) { + std::vector filters{ + { PathFilter::For::Section, "A" }, + { PathFilter::For::Generator, "1" }, + { PathFilter::For::Section, "B" }, + }; + REQUIRE( serializePathFilters( filters ) == + " - Section: \"A\"\n" + " - Generator: \"1\"\n" + " - Section: \"B\"" ); + } +} + TEST_CASE( "Reporter's write listings to provided stream", "[reporters]" ) { using Catch::Matchers::ContainsSubstring; using namespace std::string_literals;