Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Fix vendored dep because upstream is non-responsive

Eventually this needs to be fixed in the textflow project by Phil,
but he has not done so in the half a year this bug has been known
to be there, so...

Closes #1470
Closes #1455
Commit
4e32e0a5634381740ab2ed0dba4eb307b037c0d9
Author
Martin Hořeňovský ·
Parents
1e2270b37091

Files · Download .tar.gz

Changes

 include/external/clara.hpp                         |  3 +++
 .../SelfTest/Baselines/compact.sw.approved.txt     |  5 ++++-
 .../SelfTest/Baselines/console.std.approved.txt    | 16 +++++++++++++---
 .../SelfTest/Baselines/console.sw.approved.txt     | 19 +++++++++++++++++--
 .../SelfTest/Baselines/console.swa4.approved.txt   | 22 ++++++++++++++++------
 projects/SelfTest/Baselines/junit.sw.approved.txt  |  3 ++-
 projects/SelfTest/Baselines/xml.sw.approved.txt    | 15 +++++++++++++--
 projects/SelfTest/UsageTests/Message.tests.cpp     |  7 +++++++
 third_party/clara.hpp                              |  3 +++
 9 files changed, 78 insertions(+), 15 deletions(-)

diff --git a/include/external/clara.hpp b/include/external/clara.hpp
index 20c6da70..c7348bf9 100644
--- a/include/external/clara.hpp
+++ b/include/external/clara.hpp
@@ -111,6 +111,9 @@ public:
 			m_suffix = false;
 			auto width = m_column.m_width - indent();
 			m_end = m_pos;
+			if (line()[m_pos] == '\n') {
+				++m_end;
+			}
 			while (m_end < line().size() && line()[m_end] != '\n')
 				++m_end;
 
diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt
index 20ecb7bb..99eca94d 100644
--- a/projects/SelfTest/Baselines/compact.sw.approved.txt
+++ b/projects/SelfTest/Baselines/compact.sw.approved.txt
@@ -14,6 +14,9 @@ Compilation.tests.cpp:<line number>: passed: std::memcmp(uarr, "123", sizeof(uar
 Compilation.tests.cpp:<line number>: passed: std::memcmp(sarr, "456", sizeof(sarr)) == 0 for: 0 == 0 with 2 messages: 'uarr := "123"' and 'sarr := "456"'
 Compilation.tests.cpp:<line number>: passed:
 Compilation.tests.cpp:<line number>: passed: h1 == h2 for: [1403 helper] == [1403 helper]
+Message.tests.cpp:<line number>: warning: '
+This info message starts with a linebreak' with 1 message: '
+This warning message starts with a linebreak'
 This would not be caught previously
 Nor would this
 Tricky.tests.cpp:<line number>: failed: explicitly with 1 message: '1514'
@@ -1502,5 +1505,5 @@ Misc.tests.cpp:<line number>: passed: v.size() == 5 for: 5 == 5
 Misc.tests.cpp:<line number>: passed: v.capacity() >= 5 for: 5 >= 5
 Misc.tests.cpp:<line number>: passed:
 Misc.tests.cpp:<line number>: passed:
-Failed 77 test cases, failed 138 assertions.
+Failed 78 test cases, failed 139 assertions.
 
diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt
index d69a96c7..3b6f2068 100644
--- a/projects/SelfTest/Baselines/console.std.approved.txt
+++ b/projects/SelfTest/Baselines/console.std.approved.txt
@@ -1,6 +1,4 @@
 Filters: ~[!nonportable]~[!benchmark]~[approvals]
-This would not be caught previously
-Nor would this
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <exe-name> is a <version> host application.
@@ -8,6 +6,18 @@ Run with -? for options
 
 Randomness seeded to: 1
 
+-------------------------------------------------------------------------------
+#1455 - INFO and WARN can start with a linebreak
+-------------------------------------------------------------------------------
+Message.tests.cpp:<line number>
+...............................................................................
+
+Message.tests.cpp:<line number>: warning:
+
+This warning message starts with a linebreak
+
+This would not be caught previously
+Nor would this
 -------------------------------------------------------------------------------
 #1514: stderr/stdout is not captured in tests aborted by an exception
 -------------------------------------------------------------------------------
@@ -1265,6 +1275,6 @@ due to unexpected exception with message:
   Why would you throw a std::string?
 
 ===============================================================================
-test cases:  257 |  191 passed |  62 failed |  4 failed as expected
+test cases:  258 |  192 passed |  62 failed |  4 failed as expected
 assertions: 1419 | 1276 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 d7a16282..c63de78a 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -134,6 +134,21 @@ Compilation.tests.cpp:<line number>: PASSED:
 with expansion:
   [1403 helper] == [1403 helper]
 
+-------------------------------------------------------------------------------
+#1455 - INFO and WARN can start with a linebreak
+-------------------------------------------------------------------------------
+Message.tests.cpp:<line number>
+...............................................................................
+
+Message.tests.cpp:<line number>: warning:
+
+This info message starts with a linebreak
+
+This warning message starts with a linebreak
+
+
+No assertions in test case '#1455 - INFO and WARN can start with a linebreak'
+
 This would not be caught previously
 Nor would this
 -------------------------------------------------------------------------------
@@ -11113,6 +11128,6 @@ Misc.tests.cpp:<line number>
 Misc.tests.cpp:<line number>: PASSED:
 
 ===============================================================================
-test cases:  257 |  176 passed |  77 failed |  4 failed as expected
-assertions: 1435 | 1276 passed | 138 failed | 21 failed as expected
+test cases:  258 |  176 passed |  78 failed |  4 failed as expected
+assertions: 1436 | 1276 passed | 139 failed | 21 failed as expected
 
diff --git a/projects/SelfTest/Baselines/console.swa4.approved.txt b/projects/SelfTest/Baselines/console.swa4.approved.txt
index d3da8934..bfa66750 100644
--- a/projects/SelfTest/Baselines/console.swa4.approved.txt
+++ b/projects/SelfTest/Baselines/console.swa4.approved.txt
@@ -134,6 +134,21 @@ Compilation.tests.cpp:<line number>: PASSED:
 with expansion:
   [1403 helper] == [1403 helper]
 
+-------------------------------------------------------------------------------
+#1455 - INFO and WARN can start with a linebreak
+-------------------------------------------------------------------------------
+Message.tests.cpp:<line number>
+...............................................................................
+
+Message.tests.cpp:<line number>: warning:
+
+This info message starts with a linebreak
+
+This warning message starts with a linebreak
+
+
+No assertions in test case '#1455 - INFO and WARN can start with a linebreak'
+
 This would not be caught previously
 Nor would this
 -------------------------------------------------------------------------------
@@ -336,12 +351,7 @@ Condition.tests.cpp:<line number>: FAILED:
 Condition.tests.cpp:<line number>: FAILED:
   CHECK( true != true )
 
-Condition.tests.cpp:<line number>: FAILED:
-  CHECK( !true )
-with expansion:
-  false
-
 ===============================================================================
-test cases: 17 | 13 passed | 2 failed | 2 failed as expected
+test cases: 18 | 13 passed | 3 failed | 2 failed as expected
 assertions: 40 | 33 passed | 4 failed | 3 failed as expected
 
diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt
index e985133b..ed0ecfc5 100644
--- a/projects/SelfTest/Baselines/junit.sw.approved.txt
+++ b/projects/SelfTest/Baselines/junit.sw.approved.txt
@@ -5,7 +5,7 @@
     <property name="random-seed" value="1"/>
   </properties>
 loose text artifact
-  <testsuite name="<exe-name>" errors="17" failures="122" tests="1436" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+  <testsuite name="<exe-name>" errors="17" failures="123" tests="1437" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
     <testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
@@ -14,6 +14,7 @@ loose text artifact
     <testcase classname="<exe-name>.global" name="#1238" time="{duration}"/>
     <testcase classname="<exe-name>.(Fixture_1245&lt;int, int>)" name="#1245" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="#1403" time="{duration}"/>
+    <testcase classname="<exe-name>.global" name="#1455 - INFO and WARN can start with a linebreak" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="#1514: stderr/stdout is not captured in tests aborted by an exception" time="{duration}">
       <failure type="FAIL">
 1514
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index 20fc7f70..b526a5f7 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -142,6 +142,17 @@
       </Expression>
       <OverallResult success="true"/>
     </TestCase>
+    <TestCase name="#1455 - INFO and WARN can start with a linebreak" tags="[.][messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
+      <Info>
+
+This info message starts with a linebreak
+      </Info>
+      <Warning>
+
+This warning message starts with a linebreak
+      </Warning>
+      <OverallResult success="false"/>
+    </TestCase>
     <TestCase name="#1514: stderr/stdout is not captured in tests aborted by an exception" tags="[.][output-capture][regression]" filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
       <Failure filename="projects/<exe-name>/UsageTests/Tricky.tests.cpp" >
         1514
@@ -13388,7 +13399,7 @@ loose text artifact
       </Section>
       <OverallResult success="true"/>
     </TestCase>
-    <OverallResults successes="1276" failures="139" expectedFailures="21"/>
+    <OverallResults successes="1276" failures="140" expectedFailures="21"/>
   </Group>
-  <OverallResults successes="1276" failures="138" expectedFailures="21"/>
+  <OverallResults successes="1276" failures="139" expectedFailures="21"/>
 </Catch>
diff --git a/projects/SelfTest/UsageTests/Message.tests.cpp b/projects/SelfTest/UsageTests/Message.tests.cpp
index c955822f..50992ceb 100644
--- a/projects/SelfTest/UsageTests/Message.tests.cpp
+++ b/projects/SelfTest/UsageTests/Message.tests.cpp
@@ -14,6 +14,13 @@ TEST_CASE( "INFO and WARN do not abort tests", "[messages][.]" ) {
     WARN( "this is a " << "warning" );    // This should always output the message but then continue
 }
 
+TEST_CASE( "#1455 - INFO and WARN can start with a linebreak", "[messages][.]" ) {
+    // Previously these would be hidden from the console reporter output,
+    // because it would fail at properly reflowing the text
+    INFO( "\nThis info message starts with a linebreak" );
+    WARN( "\nThis warning message starts with a linebreak" );
+}
+
 TEST_CASE( "SUCCEED counts as a test pass", "[messages]" ) {
     SUCCEED( "this is a " << "success" );
 }
diff --git a/third_party/clara.hpp b/third_party/clara.hpp
index 6be5a98b..9f4f1b2c 100644
--- a/third_party/clara.hpp
+++ b/third_party/clara.hpp
@@ -110,6 +110,9 @@ namespace clara { namespace TextFlow {
                 m_suffix = false;
                 auto width = m_column.m_width-indent();
                 m_end = m_pos;
+                if (line()[m_pos] == '\n') {
+                    ++m_end;
+                }
                 while( m_end < line().size() && line()[m_end] != '\n' )
                     ++m_end;