From b77cec05c0b3a089e69a709e07c964ff842e5611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Fri, 29 Mar 2019 10:48:56 +0100 Subject: [PATCH] Fix test tag parsing to split [.foo] into [.][foo] --- include/internal/catch_test_case_info.cpp | 6 +++ projects/CMakeLists.txt | 2 +- .../Baselines/compact.sw.approved.txt | 17 +++---- .../Baselines/console.std.approved.txt | 4 +- .../Baselines/console.sw.approved.txt | 35 ++++++++++----- .../SelfTest/Baselines/junit.sw.approved.txt | 3 +- .../SelfTest/Baselines/xml.sw.approved.txt | 45 ++++++++++++------- .../{TagAlias.tests.cpp => Tag.tests.cpp} | 5 +++ 8 files changed, 76 insertions(+), 41 deletions(-) rename projects/SelfTest/IntrospectiveTests/{TagAlias.tests.cpp => Tag.tests.cpp} (84%) diff --git a/include/internal/catch_test_case_info.cpp b/include/internal/catch_test_case_info.cpp index 536462d1..e600a5e9 100644 --- a/include/internal/catch_test_case_info.cpp +++ b/include/internal/catch_test_case_info.cpp @@ -75,6 +75,12 @@ namespace Catch { else if( prop == TestCaseInfo::None ) enforceNotReservedTag( tag, _lineInfo ); + // Merged hide tags like `[.approvals]` should be added as + // `[.][approvals]`. The `[.]` is added at later point, so + // we only strip the prefix + if (startsWith(tag, '.') && tag.size() > 1) { + tag.erase(0, 1); + } tags.push_back( tag ); tag.clear(); inTag = false; diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index b3caa82f..37b0865a 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -19,7 +19,7 @@ set(TEST_SOURCES ${SELF_TEST_DIR}/IntrospectiveTests/CmdLine.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/GeneratorsImpl.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/PartTracker.tests.cpp - ${SELF_TEST_DIR}/IntrospectiveTests/TagAlias.tests.cpp + ${SELF_TEST_DIR}/IntrospectiveTests/Tag.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/String.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp ${SELF_TEST_DIR}/UsageTests/Approx.tests.cpp diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index 5b338078..4aace675 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -1004,22 +1004,22 @@ Misc.tests.cpp:: failed: s1 == s2 for: "if ($b == 10) { $a = 20; } " -TagAlias.tests.cpp:: passed: what, Contains( "[@zzz]" ) for: "error: tag alias, '[@zzz]' already registered. +Tag.tests.cpp:: passed: what, Contains( "[@zzz]" ) for: "error: tag alias, '[@zzz]' already registered. First seen at: file:2 Redefined at: file:10" contains: "[@zzz]" -TagAlias.tests.cpp:: passed: what, Contains( "file" ) for: "error: tag alias, '[@zzz]' already registered. +Tag.tests.cpp:: passed: what, Contains( "file" ) for: "error: tag alias, '[@zzz]' already registered. First seen at: file:2 Redefined at: file:10" contains: "file" -TagAlias.tests.cpp:: passed: what, Contains( "2" ) for: "error: tag alias, '[@zzz]' already registered. +Tag.tests.cpp:: passed: what, Contains( "2" ) for: "error: tag alias, '[@zzz]' already registered. First seen at: file:2 Redefined at: file:10" contains: "2" -TagAlias.tests.cpp:: passed: what, Contains( "10" ) for: "error: tag alias, '[@zzz]' already registered. +Tag.tests.cpp:: passed: what, Contains( "10" ) for: "error: tag alias, '[@zzz]' already registered. First seen at: file:2 Redefined at: file:10" contains: "10" -TagAlias.tests.cpp:: passed: registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) -TagAlias.tests.cpp:: passed: registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) -TagAlias.tests.cpp:: passed: registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) -TagAlias.tests.cpp:: passed: registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) +Tag.tests.cpp:: passed: registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) +Tag.tests.cpp:: passed: registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) +Tag.tests.cpp:: passed: registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) +Tag.tests.cpp:: passed: registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 Misc.tests.cpp:: passed: v.size() == 10 for: 10 == 10 @@ -1362,6 +1362,7 @@ String.tests.cpp:: passed: Catch::replaceInPlace( s, "'", "|'" ) fo String.tests.cpp:: passed: s == "didn|'t" for: "didn|'t" == "didn|'t" Misc.tests.cpp:: failed: false with 1 message: '3' Message.tests.cpp:: failed: false with 2 messages: 'hi' and 'i := 7' +Tag.tests.cpp:: passed: testcase.tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")) for: { ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." ) Message.tests.cpp:: failed: false with 4 messages: 'Count 1 to 3...' and '1' and '2' and '3' Message.tests.cpp:: failed: false with 4 messages: 'Count 4 to 6...' and '4' and '5' and '6' ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( emptyMap ) == "{ }" for: "{ }" == "{ }" diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 7fc5583b..42aa0419 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1264,6 +1264,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 255 | 189 passed | 62 failed | 4 failed as expected -assertions: 1402 | 1259 passed | 122 failed | 21 failed as expected +test cases: 256 | 190 passed | 62 failed | 4 failed as expected +assertions: 1403 | 1260 passed | 122 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 0f7b5404..49babee0 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -7315,31 +7315,31 @@ with expansion: Tag alias can be registered against tag patterns The same tag alias can only be registered once ------------------------------------------------------------------------------- -TagAlias.tests.cpp: +Tag.tests.cpp: ............................................................................... -TagAlias.tests.cpp:: PASSED: +Tag.tests.cpp:: PASSED: CHECK_THAT( what, Contains( "[@zzz]" ) ) with expansion: "error: tag alias, '[@zzz]' already registered. First seen at: file:2 Redefined at: file:10" contains: "[@zzz]" -TagAlias.tests.cpp:: PASSED: +Tag.tests.cpp:: PASSED: CHECK_THAT( what, Contains( "file" ) ) with expansion: "error: tag alias, '[@zzz]' already registered. First seen at: file:2 Redefined at: file:10" contains: "file" -TagAlias.tests.cpp:: PASSED: +Tag.tests.cpp:: PASSED: CHECK_THAT( what, Contains( "2" ) ) with expansion: "error: tag alias, '[@zzz]' already registered. First seen at: file:2 Redefined at: file:10" contains: "2" -TagAlias.tests.cpp:: PASSED: +Tag.tests.cpp:: PASSED: CHECK_THAT( what, Contains( "10" ) ) with expansion: "error: tag alias, '[@zzz]' already registered. @@ -7350,19 +7350,19 @@ with expansion: Tag alias can be registered against tag patterns Tag aliases must be of the form [@name] ------------------------------------------------------------------------------- -TagAlias.tests.cpp: +Tag.tests.cpp: ............................................................................... -TagAlias.tests.cpp:: PASSED: +Tag.tests.cpp:: PASSED: CHECK_THROWS( registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) ) -TagAlias.tests.cpp:: PASSED: +Tag.tests.cpp:: PASSED: CHECK_THROWS( registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) ) -TagAlias.tests.cpp:: PASSED: +Tag.tests.cpp:: PASSED: CHECK_THROWS( registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) ) -TagAlias.tests.cpp:: PASSED: +Tag.tests.cpp:: PASSED: CHECK_THROWS( registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) ) ------------------------------------------------------------------------------- @@ -10084,6 +10084,17 @@ with messages: hi i := 7 +------------------------------------------------------------------------------- +shortened hide tags are split apart +------------------------------------------------------------------------------- +Tag.tests.cpp: +............................................................................... + +Tag.tests.cpp:: PASSED: + REQUIRE_THAT( testcase.tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")) ) +with expansion: + { ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." ) + ------------------------------------------------------------------------------- stacks unscoped info in loops ------------------------------------------------------------------------------- @@ -10925,6 +10936,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 255 | 174 passed | 77 failed | 4 failed as expected -assertions: 1418 | 1259 passed | 138 failed | 21 failed as expected +test cases: 256 | 175 passed | 77 failed | 4 failed as expected +assertions: 1419 | 1260 passed | 138 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index f9f8754b..cbef6f92 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -4,7 +4,7 @@ loose text artifact - + @@ -980,6 +980,7 @@ i := 7 Message.tests.cpp: + Count 1 to 3... diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index ec19c14d..1aecca38 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -2916,7 +2916,7 @@ Nor would this - +
@@ -5861,7 +5861,7 @@ Nor would this - + testStringForMatching(), (Contains("string") || Contains("different")) && Contains("random") @@ -5883,7 +5883,7 @@ Nor would this - + testStringForMatching(), !Contains("substring") @@ -8205,7 +8205,7 @@ Nor would this - + testStringForMatching(), Matches("this STRING contains 'abc' as a substring") @@ -9186,9 +9186,9 @@ Message from section two - -
- + +
+ what, Contains( "[@zzz]" ) @@ -9198,7 +9198,7 @@ Message from section two Redefined at: file:10" contains: "[@zzz]" - + what, Contains( "file" ) @@ -9208,7 +9208,7 @@ Message from section two Redefined at: file:10" contains: "file" - + what, Contains( "2" ) @@ -9218,7 +9218,7 @@ Message from section two Redefined at: file:10" contains: "2" - + what, Contains( "10" ) @@ -9230,8 +9230,8 @@ Message from section two
-
- +
+ registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) @@ -9239,7 +9239,7 @@ Message from section two registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) - + registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) @@ -9247,7 +9247,7 @@ Message from section two registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) - + registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) @@ -9255,7 +9255,7 @@ Message from section two registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) - + registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) @@ -12352,6 +12352,17 @@ loose text artifact + + + + testcase.tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")) + + + { ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." ) + + + + Count 1 to 3... @@ -13246,7 +13257,7 @@ loose text artifact
- + - + diff --git a/projects/SelfTest/IntrospectiveTests/TagAlias.tests.cpp b/projects/SelfTest/IntrospectiveTests/Tag.tests.cpp similarity index 84% rename from projects/SelfTest/IntrospectiveTests/TagAlias.tests.cpp rename to projects/SelfTest/IntrospectiveTests/Tag.tests.cpp index b533c454..27958223 100644 --- a/projects/SelfTest/IntrospectiveTests/TagAlias.tests.cpp +++ b/projects/SelfTest/IntrospectiveTests/Tag.tests.cpp @@ -40,3 +40,8 @@ TEST_CASE( "Tag alias can be registered against tag patterns" ) { CHECK_THROWS( registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) ); } } + +TEST_CASE("shortened hide tags are split apart") { + auto testcase = Catch::makeTestCase(nullptr, "", {"fake test name", "[.magic-tag]"}, CATCH_INTERNAL_LINEINFO); + REQUIRE_THAT(testcase.tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string("."))); +}