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

Don't run tests starting with ./ by default. Changed all low-level self tests to be in ./

Commit
684baf105378fc5a90cbebd9e5c7e8898989983e
Author
Phil Nash ·
Parents
f36d77734378

Files · Download .tar.gz

Changes

 Test/ClassTests.cpp               |  8 ++++----
 Test/ConditionTests.cpp           | 16 ++++++++--------
 Test/ExceptionTests.cpp           |  8 ++++----
 Test/MessageTests.cpp             |  8 ++++----
 Test/MiscTests.cpp                | 10 +++++-----
 Test/TestMain.cpp                 |  8 ++++----
 Test/TrickyTests.cpp              |  6 +++---
 internal/catch_runner_impl.hpp    |  3 ++-
 internal/catch_test_case_info.hpp |  8 ++++++++
 9 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/Test/ClassTests.cpp b/Test/ClassTests.cpp
index c4be09c2..8d456d4e 100644
--- a/Test/ClassTests.cpp
+++ b/Test/ClassTests.cpp
@@ -35,8 +35,8 @@ namespace
 }
 
 
-METHOD_AS_TEST_CASE( TestClass::succeedingCase, "succeeding/TestClass/succeedingCase", "A method based test run that succeeds" );
-METHOD_AS_TEST_CASE( TestClass::failingCase, "failing/TestClass/failingCase", "A method based test run that fails" );
+METHOD_AS_TEST_CASE( TestClass::succeedingCase, "./succeeding/TestClass/succeedingCase", "A method based test run that succeeds" );
+METHOD_AS_TEST_CASE( TestClass::failingCase, "./failing/TestClass/failingCase", "A method based test run that fails" );
 
 
 struct Fixture
@@ -46,12 +46,12 @@ struct Fixture
     int m_a;
 };
 
-TEST_CASE_METHOD( Fixture, "succeeding/Fixture/succeedingCase", "A method based test run that succeeds" )
+TEST_CASE_METHOD( Fixture, "./succeeding/Fixture/succeedingCase", "A method based test run that succeeds" )
 {   
     REQUIRE( m_a == 1 );        
 }
 
-TEST_CASE_METHOD( Fixture, "failing/Fixture/failingCase", "A method based test run that fails" )
+TEST_CASE_METHOD( Fixture, "./failing/Fixture/failingCase", "A method based test run that fails" )
 {   
     REQUIRE( m_a == 2 );        
 }
diff --git a/Test/ConditionTests.cpp b/Test/ConditionTests.cpp
index 5f8ce7f6..3a92ebff 100644
--- a/Test/ConditionTests.cpp
+++ b/Test/ConditionTests.cpp
@@ -33,7 +33,7 @@ struct TestData
 // This allows us to see all results, even if an earlier check fails
 
 // Equality tests
-TEST_CASE( "succeeding/conditions/equality", "Equality checks that should succeed" )
+TEST_CASE( "./succeeding/conditions/equality", "Equality checks that should succeed" )
 {
     TestData data;
     
@@ -47,7 +47,7 @@ TEST_CASE( "succeeding/conditions/equality", "Equality checks that should succee
     REQUIRE( x == Approx( 1.3 ) );
 }
 
-TEST_CASE( "failing/conditions/equality", "Equality checks that should fail" )
+TEST_CASE( "./failing/conditions/equality", "Equality checks that should fail" )
 {
     TestData data;
     
@@ -68,7 +68,7 @@ TEST_CASE( "failing/conditions/equality", "Equality checks that should fail" )
     CHECK( x == Approx( 1.301 ) );
 }
 
-TEST_CASE( "succeeding/conditions/inequality", "Inequality checks that should succeed" )
+TEST_CASE( "./succeeding/conditions/inequality", "Inequality checks that should succeed" )
 {
     TestData data;
     
@@ -85,7 +85,7 @@ TEST_CASE( "succeeding/conditions/inequality", "Inequality checks that should su
     REQUIRE( data.str_hello.size() != 6 );
 }
 
-TEST_CASE( "failing/conditions/inequality", "Inequality checks that should fails" )
+TEST_CASE( "./failing/conditions/inequality", "Inequality checks that should fails" )
 {
     TestData data;
     
@@ -97,7 +97,7 @@ TEST_CASE( "failing/conditions/inequality", "Inequality checks that should fails
 }
 
 // Ordering comparison tests
-TEST_CASE( "succeeding/conditions/ordered", "Ordering comparison checks that should succeed" )
+TEST_CASE( "./succeeding/conditions/ordered", "Ordering comparison checks that should succeed" )
 {
     TestData data;
     
@@ -124,7 +124,7 @@ TEST_CASE( "succeeding/conditions/ordered", "Ordering comparison checks that sho
     REQUIRE( data.str_hello > "a" );
 }
 
-TEST_CASE( "failing/conditions/ordered", "Ordering comparison checks that should fail" )
+TEST_CASE( "./failing/conditions/ordered", "Ordering comparison checks that should fail" )
 {
     TestData data;
     
@@ -160,7 +160,7 @@ TEST_CASE( "failing/conditions/ordered", "Ordering comparison checks that should
 // is detected and a warning issued.
 // An alternative form of the macros (CHECK_FALSE and REQUIRE_FALSE) can be used instead to capture
 // the operand value.
-TEST_CASE( "succeeding/conditions/not", "'Not' checks that should succeed" )
+TEST_CASE( "./succeeding/conditions/not", "'Not' checks that should succeed" )
 {
     bool falseValue = false;
     
@@ -174,7 +174,7 @@ TEST_CASE( "succeeding/conditions/not", "'Not' checks that should succeed" )
     REQUIRE_FALSE( 1 == 2 );
 }
 
-TEST_CASE( "failing/conditions/not", "'Not' checks that should fail" )
+TEST_CASE( "./failing/conditions/not", "'Not' checks that should fail" )
 {
     bool trueValue = true;
     
diff --git a/Test/ExceptionTests.cpp b/Test/ExceptionTests.cpp
index 4be5a193..db5786cb 100644
--- a/Test/ExceptionTests.cpp
+++ b/Test/ExceptionTests.cpp
@@ -28,26 +28,26 @@ namespace
     }
 }
 
-TEST_CASE( "succeeding/exceptions/explicit", "When checked exceptions are thrown they can be expected or unexpected" )
+TEST_CASE( "./succeeding/exceptions/explicit", "When checked exceptions are thrown they can be expected or unexpected" )
 {
     REQUIRE_THROWS_AS( thisThrows(), std::domain_error );
     REQUIRE_NOTHROW( thisDoesntThrow() );
     REQUIRE_THROWS( thisThrows() );
 }
 
-TEST_CASE( "failing/exceptions/explicit", "When checked exceptions are thrown they can be expected or unexpected" )
+TEST_CASE( "./failing/exceptions/explicit", "When checked exceptions are thrown they can be expected or unexpected" )
 {
     CHECK_THROWS_AS( thisThrows(), std::string );
     CHECK_THROWS_AS( thisDoesntThrow(), std::domain_error );
     CHECK_NOTHROW( thisThrows() );
 }
 
-TEST_CASE( "failing/exceptions/implicit", "When unchecked exceptions are thrown they are always failures" )
+TEST_CASE( "./failing/exceptions/implicit", "When unchecked exceptions are thrown they are always failures" )
 {
     throw std::domain_error( "unexpected exception" );
 }
 
-TEST_CASE( "succeeding/exceptions/implicit", "When unchecked exceptions are thrown, but caught, they do not affect the test" )
+TEST_CASE( "./succeeding/exceptions/implicit", "When unchecked exceptions are thrown, but caught, they do not affect the test" )
 {
     try
     {
diff --git a/Test/MessageTests.cpp b/Test/MessageTests.cpp
index ca58c5e7..a8e067ed 100644
--- a/Test/MessageTests.cpp
+++ b/Test/MessageTests.cpp
@@ -12,13 +12,13 @@
 
 #include "../catch.hpp"
 
-TEST_CASE( "succeeding/message", "INFO and WARN do not abort tests" )
+TEST_CASE( "./succeeding/message", "INFO and WARN do not abort tests" )
 {
     INFO( "this is a " << "message" );    // This should output the message if a failure occurs
     WARN( "this is a " << "warning" );    // This should always output the message but then continue
 }
 
-TEST_CASE( "failing/message/info/1", "INFO gets logged on failure" )
+TEST_CASE( "./failing/message/info/1", "INFO gets logged on failure" )
 {
     INFO( "this message should be logged" );
     INFO( "so should this" );
@@ -26,7 +26,7 @@ TEST_CASE( "failing/message/info/1", "INFO gets logged on failure" )
     REQUIRE( a == 1 );
 }
 
-TEST_CASE( "mixed/message/info/2", "INFO gets logged on failure" )
+TEST_CASE( "./mixed/message/info/2", "INFO gets logged on failure" )
 {
     INFO( "this message should be logged" );
     int a = 2;
@@ -45,7 +45,7 @@ TEST_CASE( "mixed/message/info/2", "INFO gets logged on failure" )
     CHECK( a == 2 );
 }
 
-TEST_CASE( "failing/message/fail", "FAIL aborts the test" )
+TEST_CASE( "./failing/message/fail", "FAIL aborts the test" )
 {
     FAIL( "This is a " << "failure" );    // This should output the message and abort
 }
\ No newline at end of file
diff --git a/Test/MiscTests.cpp b/Test/MiscTests.cpp
index 138596bb..7f0da4f8 100644
--- a/Test/MiscTests.cpp
+++ b/Test/MiscTests.cpp
@@ -13,7 +13,7 @@
 #include "../catch.hpp"
 #include <iostream>
 
-TEST_CASE( "succeeding/Misc/Sections", "random SECTION tests" )
+TEST_CASE( "./succeeding/Misc/Sections", "random SECTION tests" )
 {
     int a = 1;
     int b = 2;
@@ -30,7 +30,7 @@ TEST_CASE( "succeeding/Misc/Sections", "random SECTION tests" )
     }
 }
 
-TEST_CASE( "succeeding/Misc/Sections/nested", "nested SECTION tests" )
+TEST_CASE( "./succeeding/Misc/Sections/nested", "nested SECTION tests" )
 {
     int a = 1;
     int b = 2;
@@ -47,7 +47,7 @@ TEST_CASE( "succeeding/Misc/Sections/nested", "nested SECTION tests" )
     }
 }
 
-TEST_CASE( "mixed/Misc/Sections/loops", "looped SECTION tests" )
+TEST_CASE( "./mixed/Misc/Sections/loops", "looped SECTION tests" )
 {
     int a = 1;
     
@@ -62,7 +62,7 @@ TEST_CASE( "mixed/Misc/Sections/loops", "looped SECTION tests" )
     }
 }
 
-TEST_CASE( "mixed/Misc/loops", "looped tests" )
+TEST_CASE( "./mixed/Misc/loops", "looped tests" )
 {
     static const int fib[]  = { 1, 1, 2, 3, 5, 8, 13, 21 };
     
@@ -73,7 +73,7 @@ TEST_CASE( "mixed/Misc/loops", "looped tests" )
     }
 }
 
-TEST_CASE( "succeeding/Misc/stdout,stderr", "Sends stuff to stdout and stderr" )
+TEST_CASE( "./succeeding/Misc/stdout,stderr", "Sends stuff to stdout and stderr" )
 {
     std::cout << "Some information";
     
diff --git a/Test/TestMain.cpp b/Test/TestMain.cpp
index 7ca6ce6b..910aa094 100644
--- a/Test/TestMain.cpp
+++ b/Test/TestMain.cpp
@@ -19,13 +19,13 @@ TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results"
     
     {
         EmbeddedRunner runner;
-        runner.runMatching( "succeeding/*" );
+        runner.runMatching( "./succeeding/*" );
         CHECK( runner.getReporter().getSucceeded() == 53 );
         CHECK( runner.getReporter().getFailed() == 0 );
     }
     {
         EmbeddedRunner runner;
-        runner.runMatching( "failing/*" );
+        runner.runMatching( "./failing/*" );
         
         CHECK( runner.getReporter().getSucceeded() == 0 );
         CHECK( runner.getReporter().getFailed() == 53 );
@@ -42,7 +42,7 @@ TEST_CASE( "selftest/succeeding", "Runs all Catch self tests that should succeed
         SelfTestConfig config;
         {
             Runner runner( config );
-            runner.runMatching( "succeeding/*" );
+            runner.runMatching( "./succeeding/*" );
         }
         
         CHECK( config.getReporter().getSucceeded() == 53 );
@@ -60,7 +60,7 @@ TEST_CASE( "selftest/failing", "Runs all Catch self tests that should fail and c
         SelfTestConfig config;
         {
             Runner runner( config );
-            runner.runMatching( "failing/*" );
+            runner.runMatching( "./failing/*" );
         }
         
         CHECK( config.getReporter().getSucceeded() == 0 );
diff --git a/Test/TrickyTests.cpp b/Test/TrickyTests.cpp
index 88ed5962..69e54bb0 100644
--- a/Test/TrickyTests.cpp
+++ b/Test/TrickyTests.cpp
@@ -24,7 +24,7 @@ namespace Catch
     }
 }
 
-TEST_CASE( "succeeding/Tricky/std::pair", "Parsing a std::pair" )
+TEST_CASE( "./succeeding/Tricky/std::pair", "Parsing a std::pair" )
 {
     std::pair<int, int> aNicePair( 1, 2 );
 
@@ -33,7 +33,7 @@ TEST_CASE( "succeeding/Tricky/std::pair", "Parsing a std::pair" )
     
 }
 
-TEST_CASE( "succeeding/Tricky/complex lhs", "Where the LHS is not a simple value" )
+TEST_CASE( "./succeeding/Tricky/complex lhs", "Where the LHS is not a simple value" )
 {
     int a = 1;
     int b = 2;
@@ -51,7 +51,7 @@ struct Opaque
     }
 };
 
-TEST_CASE( "failing/Tricky/non streamable type", "A failing expression with a non streamable type is still captured" )
+TEST_CASE( "./failing/Tricky/non streamable type", "A failing expression with a non streamable type is still captured" )
 {
     
     Opaque o1, o2;
diff --git a/internal/catch_runner_impl.hpp b/internal/catch_runner_impl.hpp
index 258cb83c..d323c35c 100644
--- a/internal/catch_runner_impl.hpp
+++ b/internal/catch_runner_impl.hpp
@@ -113,7 +113,8 @@ namespace Catch
             std::vector<TestCaseInfo> allTests = Hub::getTestCaseRegistry().getAllTests();
             for( std::size_t i=0; i < allTests.size(); ++i )
             {
-                runTest( allTests[i] );
+                if( !allTests[i].isHidden() )
+                   runTest( allTests[i] );
             }
         }
         
diff --git a/internal/catch_test_case_info.hpp b/internal/catch_test_case_info.hpp
index 737f79fb..cdf8e900 100644
--- a/internal/catch_test_case_info.hpp
+++ b/internal/catch_test_case_info.hpp
@@ -94,6 +94,14 @@ namespace Catch
         {
             return m_description;
         }
+
+        ///////////////////////////////////////////////////////////////////////
+        bool isHidden
+        ()
+        const
+        {
+            return m_name.size() >= 2 && m_name[0] == '.' && m_name[1] == '/';
+        }        
         
         ///////////////////////////////////////////////////////////////////////
         void swap