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 matching of non-lowercase filename tags

The bug was caused by forgetting to lower-case the filename tag
for matching against test spec.

Fixes #2064
Commit
8878f90323f7229b391f18e467113cb654fbdc06
Author
Martin Hořeňovský ·
Parents
0c7f96ba630a

Files · Download .tar.gz

Changes

 src/catch2/catch_test_case_info.cpp | 3 +++
 tests/CMakeLists.txt                | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/src/catch2/catch_test_case_info.cpp b/src/catch2/catch_test_case_info.cpp
index a20bc791..e8029e9c 100644
--- a/src/catch2/catch_test_case_info.cpp
+++ b/src/catch2/catch_test_case_info.cpp
@@ -190,6 +190,9 @@ namespace Catch {
         std::string combined("#");
         combined += extractFilenamePart(lineInfo.file);
         internalAppendTag(combined);
+        // TBD: Running this over all tags again is inefficient, but
+        //      simple enough. In practice, the overhead is small enough.
+        toLowerInPlace(backingLCaseTags);
     }
 
     std::string TestCaseInfo::tagsAsString() const {
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 13608bd7..c213dc67 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -181,6 +181,10 @@ set_tests_properties(LibIdentityTest PROPERTIES PASS_REGULAR_EXPRESSION "descrip
 add_test(NAME FilenameAsTagsTest COMMAND $<TARGET_FILE:SelfTest> -\# --list-tags)
 set_tests_properties(FilenameAsTagsTest PROPERTIES PASS_REGULAR_EXPRESSION "\\[#Approx.tests\\]")
 
+# Check that the filename tags can also be matched against (#2064)
+add_test(NAME FilenameAsTagsMatching COMMAND $<TARGET_FILE:SelfTest> -\# --list-tags [\#Approx.tests])
+set_tests_properties(FilenameAsTagsMatching PROPERTIES PASS_REGULAR_EXPRESSION "\\[#Approx.tests\\]")
+
 add_test(NAME EscapeSpecialCharactersInTestNames COMMAND $<TARGET_FILE:SelfTest> "Test with special\\, characters \"in name")
 set_tests_properties(EscapeSpecialCharactersInTestNames PROPERTIES PASS_REGULAR_EXPRESSION "1 assertion in 1 test case")