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

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-10-22 16:17:34 +0200
committerMartin Hořeňovský2020-10-22 16:20:41 +0200
commit8878f90323f7229b391f18e467113cb654fbdc06 (patch)
tree6c2308cf38560a370e76867e3021c334d6b127fa
parent0c7f96ba630a49e18e7b2fb0e5ed241b04a7898a (diff)
downloadcatch3-8878f90323f7229b391f18e467113cb654fbdc06.tar.gz
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
-rw-r--r--src/catch2/catch_test_case_info.cpp3
-rw-r--r--tests/CMakeLists.txt4
2 files changed, 7 insertions, 0 deletions
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")