Skip to content

Commit

Permalink
Make hidden tags behave identically (#1847)
Browse files Browse the repository at this point in the history
Add both `[.]` and `[!hide]` tags when registering a hidden test case, as per documentation.

Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
  • Loading branch information
dmsteck and horenmar authored Jan 31, 2020
1 parent 2d172dc commit 481f54b
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 98 deletions.
3 changes: 2 additions & 1 deletion include/internal/catch_test_case_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ namespace Catch {
}
}
if( isHidden ) {
tags.emplace_back( "." );
// Add all "hidden" tags to make them behave identically
tags.insert( tags.end(), { ".", "!hide" } );
}

TestCaseInfo info( static_cast<std::string>(nameAndTags.name), _className, desc, tags, _lineInfo );
Expand Down
5 changes: 4 additions & 1 deletion projects/SelfTest/Baselines/compact.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,9 @@ Xml.tests.cpp:<line number>: passed: encode( stringWithQuotes, Catch::XmlEncode:
"don't &quot;quote&quot; me on that"
Xml.tests.cpp:<line number>: passed: encode( "[\x01]" ) == "[\\x01]" for: "[\x01]" == "[\x01]"
Xml.tests.cpp:<line number>: passed: encode( "[\x7F]" ) == "[\\x7F]" for: "[\x7F]" == "[\x7F]"
Tag.tests.cpp:<line number>: passed: testcase.tags, VectorContains(std::string(".")) && VectorContains(std::string("!hide")) for: { "!hide", "." } ( Contains: "." and Contains: "!hide" )
Tag.tests.cpp:<line number>: passed: testcase.tags, VectorContains(std::string(".")) && VectorContains(std::string("!hide")) for: { "!hide", "." } ( Contains: "." and Contains: "!hide" )
Tag.tests.cpp:<line number>: passed: testcase.tags, VectorContains(std::string(".")) && VectorContains(std::string("!hide")) for: { "!hide", ".", "foo" } ( Contains: "." and Contains: "!hide" )
ToStringVector.tests.cpp:<line number>: passed: Catch::Detail::stringify( empty ) == "{ }" for: "{ }" == "{ }"
ToStringVector.tests.cpp:<line number>: passed: Catch::Detail::stringify( oneValue ) == "{ 42 }" for: "{ 42 }" == "{ 42 }"
ToStringVector.tests.cpp:<line number>: passed: Catch::Detail::stringify( twoValues ) == "{ 42, 250 }" for: "{ 42, 250 }" == "{ 42, 250 }"
Expand Down Expand Up @@ -1668,7 +1671,7 @@ StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(s, "'", "|'")
StringManip.tests.cpp:<line number>: passed: s == "didn|'t" for: "didn|'t" == "didn|'t"
Misc.tests.cpp:<line number>: failed: false with 1 message: '3'
Message.tests.cpp:<line number>: failed: false with 2 messages: 'hi' and 'i := 7'
Tag.tests.cpp:<line number>: passed: testcase.tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")) for: { ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." )
Tag.tests.cpp:<line number>: passed: testcase.tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")) for: { "!hide", ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." )
StringManip.tests.cpp:<line number>: passed: splitStringRef("", ','), Equals(std::vector<StringRef>()) for: { } Equals: { }
StringManip.tests.cpp:<line number>: passed: splitStringRef("abc", ','), Equals(std::vector<StringRef>{"abc"}) for: { abc } Equals: { abc }
StringManip.tests.cpp:<line number>: passed: splitStringRef("abc,def", ','), Equals(std::vector<StringRef>{"abc", "def"}) for: { abc, def } Equals: { abc, def }
Expand Down
4 changes: 2 additions & 2 deletions projects/SelfTest/Baselines/console.std.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,6 @@ due to unexpected exception with message:
Why would you throw a std::string?

===============================================================================
test cases: 304 | 230 passed | 70 failed | 4 failed as expected
assertions: 1659 | 1507 passed | 131 failed | 21 failed as expected
test cases: 305 | 231 passed | 70 failed | 4 failed as expected
assertions: 1662 | 1510 passed | 131 failed | 21 failed as expected

39 changes: 36 additions & 3 deletions projects/SelfTest/Baselines/console.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11465,6 +11465,39 @@ Xml.tests.cpp:<line number>: PASSED:
with expansion:
"[\x7F]" == "[\x7F]"

-------------------------------------------------------------------------------
adding a hide tag implicitly enables all others
-------------------------------------------------------------------------------
Tag.tests.cpp:<line number>
...............................................................................

Tag.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( testcase.tags, VectorContains(std::string(".")) && VectorContains(std::string("!hide")) )
with expansion:
{ "!hide", "." } ( Contains: "." and Contains: "!hide" )

-------------------------------------------------------------------------------
adding a hide tag implicitly enables all others
-------------------------------------------------------------------------------
Tag.tests.cpp:<line number>
...............................................................................

Tag.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( testcase.tags, VectorContains(std::string(".")) && VectorContains(std::string("!hide")) )
with expansion:
{ "!hide", "." } ( Contains: "." and Contains: "!hide" )

-------------------------------------------------------------------------------
adding a hide tag implicitly enables all others
-------------------------------------------------------------------------------
Tag.tests.cpp:<line number>
...............................................................................

Tag.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( testcase.tags, VectorContains(std::string(".")) && VectorContains(std::string("!hide")) )
with expansion:
{ "!hide", ".", "foo" } ( Contains: "." and Contains: "!hide" )

-------------------------------------------------------------------------------
array<int, N> -> toString
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -12387,7 +12420,7 @@ Tag.tests.cpp:<line number>
Tag.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( testcase.tags, Catch::VectorContains(std::string("magic-tag")) && Catch::VectorContains(std::string(".")) )
with expansion:
{ ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." )
{ "!hide", ".", "magic-tag" } ( Contains: "magic-tag" and Contains: "." )

-------------------------------------------------------------------------------
splitString
Expand Down Expand Up @@ -13251,6 +13284,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:

===============================================================================
test cases: 304 | 214 passed | 86 failed | 4 failed as expected
assertions: 1676 | 1507 passed | 148 failed | 21 failed as expected
test cases: 305 | 215 passed | 86 failed | 4 failed as expected
assertions: 1679 | 1510 passed | 148 failed | 21 failed as expected

3 changes: 2 additions & 1 deletion projects/SelfTest/Baselines/junit.sw.approved.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
<testsuite name="<exe-name>" errors="17" failures="132" tests="1677" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="132" tests="1680" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/>
<property name="random-seed" value="1"/>
Expand Down Expand Up @@ -1404,6 +1404,7 @@ Exception.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="XmlEncode/string with quotes" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/string with control char (1)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/string with control char (x7F)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="adding a hide tag implicitly enables all others" time="{duration}"/>
<testcase classname="<exe-name>.global" name="array&lt;int, N> -> toString" time="{duration}"/>
<testcase classname="<exe-name>.global" name="atomic if" time="{duration}"/>
<testcase classname="<exe-name>.global" name="boolean member" time="{duration}"/>
Expand Down
1 change: 1 addition & 0 deletions projects/SelfTest/Baselines/sonarqube.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<file path="projects/<exe-name>/IntrospectiveTests/Tag.tests.cpp">
<testCase name="Tag alias can be registered against tag patterns/The same tag alias can only be registered once" duration="{duration}"/>
<testCase name="Tag alias can be registered against tag patterns/Tag aliases must be of the form [@name]" duration="{duration}"/>
<testCase name="adding a hide tag implicitly enables all others" duration="{duration}"/>
<testCase name="shortened hide tags are split apart" duration="{duration}"/>
</file>
<file path="projects/<exe-name>/IntrospectiveTests/ToString.tests.cpp">
Expand Down
Loading

0 comments on commit 481f54b

Please sign in to comment.