Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-05-10 20:00:36 +0200
committerMartin Hořeňovský2022-05-10 20:57:59 +0200
commit5a49285e9cf203dd20b00ac7488a6a3233d60fff (patch)
tree0a232d7ec81e8f34d37d7fbbe7ccc2f212671eb2 /tests
parentae475a3c19e9b770e66ea3a2ce3eaa2debecd4c6 (diff)
downloadcatch3-5a49285e9cf203dd20b00ac7488a6a3233d60fff.tar.gz
Add --list-listeners option
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt12
-rw-r--r--tests/SelfTest/Baselines/compact.sw.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/compact.sw.multi.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/console.std.approved.txt2
-rw-r--r--tests/SelfTest/Baselines/console.sw.approved.txt17
-rw-r--r--tests/SelfTest/Baselines/console.sw.multi.approved.txt17
-rw-r--r--tests/SelfTest/Baselines/junit.sw.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/junit.sw.multi.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt1
-rw-r--r--tests/SelfTest/Baselines/tap.sw.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/tap.sw.multi.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/xml.sw.approved.txt16
-rw-r--r--tests/SelfTest/Baselines/xml.sw.multi.approved.txt16
-rw-r--r--tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp10
-rw-r--r--tests/SelfTest/TestRegistrations.cpp4
16 files changed, 109 insertions, 9 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 431dae65..fa63e7c0 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -207,6 +207,18 @@ set_tests_properties(List::Reporters::XmlOutput PROPERTIES
FAIL_REGULAR_EXPRESSION "Available reporters:"
)
+add_test(NAME List::Listeners::Output
+ COMMAND
+ $<TARGET_FILE:SelfTest> --list-listeners
+)
+set_tests_properties(List::Listeners::Output
+ PROPERTIES
+ PASS_REGULAR_EXPRESSION "Registered listeners:"
+)
+add_test(NAME List::Listeners::ExitCode
+ COMMAND
+ $<TARGET_FILE:SelfTest> --list-listeners
+)
add_test(NAME NoAssertions COMMAND $<TARGET_FILE:SelfTest> -w NoAssertions "An empty test with no assertions")
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index bc88e377..7221ac6a 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -1898,6 +1898,10 @@ Reporters.tests.cpp:<line number>: passed: listingString, ContainsSubstring( "fa
1 test case
" ( contains: "fake test name" and contains: "fakeTestTag" )
+Reporters.tests.cpp:<line number>: passed: listingString, ContainsSubstring( "fakeListener"s ) && ContainsSubstring( "fake description"s ) for: "Registered listeners:
+ fakeListener: fake description
+
+" ( contains: "fakeListener" and contains: "fake description" )
Misc.tests.cpp:<line number>: passed: with 1 message: 'oops!'
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'For some reason someone is throwing a string literal!'
PartTracker.tests.cpp:<line number>: passed: testCase.isOpen() for: true
diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
index 7d33ae33..6945b6be 100644
--- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
@@ -1891,6 +1891,10 @@ Reporters.tests.cpp:<line number>: passed: listingString, ContainsSubstring( "fa
1 test case
" ( contains: "fake test name" and contains: "fakeTestTag" )
+Reporters.tests.cpp:<line number>: passed: listingString, ContainsSubstring( "fakeListener"s ) && ContainsSubstring( "fake description"s ) for: "Registered listeners:
+ fakeListener: fake description
+
+" ( contains: "fakeListener" and contains: "fake description" )
Misc.tests.cpp:<line number>: passed: with 1 message: 'oops!'
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'For some reason someone is throwing a string literal!'
PartTracker.tests.cpp:<line number>: passed: testCase.isOpen() for: true
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index 2f01bf6f..0ad308be 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -1395,5 +1395,5 @@ due to unexpected exception with message:
===============================================================================
test cases: 391 | 315 passed | 69 failed | 7 failed as expected
-assertions: 2226 | 2071 passed | 128 failed | 27 failed as expected
+assertions: 2227 | 2072 passed | 128 failed | 27 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index 0078f507..d4a434cc 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -13445,6 +13445,21 @@ with expansion:
" ( contains: "fake test name" and contains: "fakeTestTag" )
-------------------------------------------------------------------------------
+The default listing implementation write to provided stream
+ Listing listeners
+-------------------------------------------------------------------------------
+Reporters.tests.cpp:<line number>
+...............................................................................
+
+Reporters.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( listingString, ContainsSubstring( "fakeListener"s ) && ContainsSubstring( "fake description"s ) )
+with expansion:
+ "Registered listeners:
+ fakeListener: fake description
+
+" ( contains: "fakeListener" and contains: "fake description" )
+
+-------------------------------------------------------------------------------
This test 'should' fail but doesn't
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
@@ -17935,5 +17950,5 @@ Misc.tests.cpp:<line number>: PASSED:
===============================================================================
test cases: 391 | 301 passed | 83 failed | 7 failed as expected
-assertions: 2241 | 2071 passed | 143 failed | 27 failed as expected
+assertions: 2242 | 2072 passed | 143 failed | 27 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
index 96a8268d..97b95f13 100644
--- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
@@ -13438,6 +13438,21 @@ with expansion:
" ( contains: "fake test name" and contains: "fakeTestTag" )
-------------------------------------------------------------------------------
+The default listing implementation write to provided stream
+ Listing listeners
+-------------------------------------------------------------------------------
+Reporters.tests.cpp:<line number>
+...............................................................................
+
+Reporters.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( listingString, ContainsSubstring( "fakeListener"s ) && ContainsSubstring( "fake description"s ) )
+with expansion:
+ "Registered listeners:
+ fakeListener: fake description
+
+" ( contains: "fakeListener" and contains: "fake description" )
+
+-------------------------------------------------------------------------------
This test 'should' fail but doesn't
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
@@ -17927,5 +17942,5 @@ Misc.tests.cpp:<line number>: PASSED:
===============================================================================
test cases: 391 | 301 passed | 83 failed | 7 failed as expected
-assertions: 2241 | 2071 passed | 143 failed | 27 failed as expected
+assertions: 2242 | 2072 passed | 143 failed | 27 failed as expected
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index fc059acd..e37a94ce 100644
--- a/tests/SelfTest/Baselines/junit.sw.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
- <testsuite name="<exe-name>" errors="17" failures="126" tests="2241" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="17" failures="126" tests="2242" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
@@ -1379,6 +1379,7 @@ Misc.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing tags" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing reporters" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing tests" time="{duration}" status="run"/>
+ <testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing listeners" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="This test 'should' fail but doesn't" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Thrown string literals are translated" time="{duration}" status="run">
<error type="TEST_CASE">
diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
index 06ade42c..07614974 100644
--- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
- <testsuite name="<exe-name>" errors="17" failures="126" tests="2241" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="17" failures="126" tests="2242" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="random-seed" value="1"/>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
@@ -1378,6 +1378,7 @@ Misc.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing tags" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing reporters" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing tests" time="{duration}" status="run"/>
+ <testcase classname="<exe-name>.global" name="The default listing implementation write to provided stream/Listing listeners" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="This test 'should' fail but doesn't" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Thrown string literals are translated" time="{duration}" status="run">
<error type="TEST_CASE">
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index 4cdab2d3..6e88a61f 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -220,6 +220,7 @@
<testCase name="The default listing implementation write to provided stream/Listing tags" duration="{duration}"/>
<testCase name="The default listing implementation write to provided stream/Listing reporters" duration="{duration}"/>
<testCase name="The default listing implementation write to provided stream/Listing tests" duration="{duration}"/>
+ <testCase name="The default listing implementation write to provided stream/Listing listeners" duration="{duration}"/>
</file>
<file path="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp">
<testCase name="Cout stream properly declares it writes to stdout" duration="{duration}"/>
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
index d5608195..6756a626 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
@@ -219,6 +219,7 @@
<testCase name="The default listing implementation write to provided stream/Listing tags" duration="{duration}"/>
<testCase name="The default listing implementation write to provided stream/Listing reporters" duration="{duration}"/>
<testCase name="The default listing implementation write to provided stream/Listing tests" duration="{duration}"/>
+ <testCase name="The default listing implementation write to provided stream/Listing listeners" duration="{duration}"/>
</file>
<file path="tests/<exe-name>/IntrospectiveTests/Stream.tests.cpp">
<testCase name="Cout stream properly declares it writes to stdout" duration="{duration}"/>
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index 4cd3cef3..ed0d9e0c 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -3338,6 +3338,8 @@ ok {test-number} - listingString, ContainsSubstring("[fakeTag]"s) for: "All avai
ok {test-number} - listingString, ContainsSubstring( "fake reporter"s ) && ContainsSubstring( "fake description"s ) for: "Available reporters: fake reporter: fake description " ( contains: "fake reporter" and contains: "fake description" )
# The default listing implementation write to provided stream
ok {test-number} - listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) for: "All available test cases: fake test name [fakeTestTag] 1 test case " ( contains: "fake test name" and contains: "fakeTestTag" )
+# The default listing implementation write to provided stream
+ok {test-number} - listingString, ContainsSubstring( "fakeListener"s ) && ContainsSubstring( "fake description"s ) for: "Registered listeners: fakeListener: fake description " ( contains: "fakeListener" and contains: "fake description" )
# This test 'should' fail but doesn't
ok {test-number} - with 1 message: 'oops!'
# Thrown string literals are translated
@@ -4485,5 +4487,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
-1..2241
+1..2242
diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
index a87ce7c6..874a825c 100644
--- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
@@ -3331,6 +3331,8 @@ ok {test-number} - listingString, ContainsSubstring("[fakeTag]"s) for: "All avai
ok {test-number} - listingString, ContainsSubstring( "fake reporter"s ) && ContainsSubstring( "fake description"s ) for: "Available reporters: fake reporter: fake description " ( contains: "fake reporter" and contains: "fake description" )
# The default listing implementation write to provided stream
ok {test-number} - listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) for: "All available test cases: fake test name [fakeTestTag] 1 test case " ( contains: "fake test name" and contains: "fakeTestTag" )
+# The default listing implementation write to provided stream
+ok {test-number} - listingString, ContainsSubstring( "fakeListener"s ) && ContainsSubstring( "fake description"s ) for: "Registered listeners: fakeListener: fake description " ( contains: "fakeListener" and contains: "fake description" )
# This test 'should' fail but doesn't
ok {test-number} - with 1 message: 'oops!'
# Thrown string literals are translated
@@ -4477,5 +4479,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
-1..2241
+1..2242
diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt
index 4523d64a..1dad9f6f 100644
--- a/tests/SelfTest/Baselines/xml.sw.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.approved.txt
@@ -15754,6 +15754,20 @@ Message from section two
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
+ <Section name="Listing listeners" filename="tests/<exe-name>/IntrospectiveTests/Reporters.tests.cpp" >
+ <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/IntrospectiveTests/Reporters.tests.cpp" >
+ <Original>
+ listingString, ContainsSubstring( "fakeListener"s ) &amp;&amp; ContainsSubstring( "fake description"s )
+ </Original>
+ <Expanded>
+ "Registered listeners:
+ fakeListener: fake description
+
+" ( contains: "fakeListener" and contains: "fake description" )
+ </Expanded>
+ </Expression>
+ <OverallResults successes="1" failures="0" expectedFailures="0"/>
+ </Section>
<OverallResult success="true"/>
</TestCase>
<TestCase name="This test 'should' fail but doesn't" tags="[!shouldfail][.][failing]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
@@ -21061,6 +21075,6 @@ loose text artifact
</Section>
<OverallResult success="true"/>
</TestCase>
- <OverallResults successes="2071" failures="143" expectedFailures="27"/>
+ <OverallResults successes="2072" failures="143" expectedFailures="27"/>
<OverallResultsCases successes="301" failures="83" expectedFailures="7"/>
</Catch2TestRun>
diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
index 4c20e564..6e432e40 100644
--- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
@@ -15754,6 +15754,20 @@ Message from section two
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
+ <Section name="Listing listeners" filename="tests/<exe-name>/IntrospectiveTests/Reporters.tests.cpp" >
+ <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/IntrospectiveTests/Reporters.tests.cpp" >
+ <Original>
+ listingString, ContainsSubstring( "fakeListener"s ) &amp;&amp; ContainsSubstring( "fake description"s )
+ </Original>
+ <Expanded>
+ "Registered listeners:
+ fakeListener: fake description
+
+" ( contains: "fakeListener" and contains: "fake description" )
+ </Expanded>
+ </Expression>
+ <OverallResults successes="1" failures="0" expectedFailures="0"/>
+ </Section>
<OverallResult success="true"/>
</TestCase>
<TestCase name="This test 'should' fail but doesn't" tags="[!shouldfail][.][failing]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
@@ -21060,6 +21074,6 @@ There is no extra whitespace here
</Section>
<OverallResult success="true"/>
</TestCase>
- <OverallResults successes="2071" failures="143" expectedFailures="27"/>
+ <OverallResults successes="2072" failures="143" expectedFailures="27"/>
<OverallResultsCases successes="301" failures="83" expectedFailures="7"/>
</Catch2TestRun>
diff --git a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp
index 5e8f11c7..5dde7038 100644
--- a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp
@@ -84,6 +84,16 @@ TEST_CASE( "The default listing implementation write to provided stream",
ContainsSubstring( "fake test name"s ) &&
ContainsSubstring( "fakeTestTag"s ) );
}
+ SECTION( "Listing listeners" ) {
+ std::vector<Catch::ListenerDescription> listeners(
+ { { "fakeListener"_catch_sr, "fake description" } } );
+
+ Catch::defaultListListeners( sstream.stream(), listeners );
+ auto listingString = sstream.str();
+ REQUIRE_THAT( listingString,
+ ContainsSubstring( "fakeListener"s ) &&
+ ContainsSubstring( "fake description"s ) );
+ }
}
TEST_CASE( "Reporter's write listings to provided stream", "[reporters]" ) {
diff --git a/tests/SelfTest/TestRegistrations.cpp b/tests/SelfTest/TestRegistrations.cpp
index 2586ffab..f24c913f 100644
--- a/tests/SelfTest/TestRegistrations.cpp
+++ b/tests/SelfTest/TestRegistrations.cpp
@@ -48,6 +48,10 @@ class ValidatingTestListener : public Catch::EventListenerBase {
};
public:
+ static std::string getDescription() {
+ return "Validates ordering of Catch2's listener events";
+ }
+
ValidatingTestListener(Catch::IConfig const* config) :
EventListenerBase(config) {
m_preferences.shouldReportAllAssertions = true;