diff options
author | Zack Galbreath <zack.galbreath@kitware.com> | 2021-06-16 15:38:45 (GMT) |
---|---|---|
committer | Zack Galbreath <zack.galbreath@kitware.com> | 2021-06-17 18:09:01 (GMT) |
commit | bd38749fd43c1d550f7c45e96a97cddb90c29437 (patch) | |
tree | 77a9c8b562643f5d7d49e6bb1d468fde51249aab /Source/CTest | |
parent | 11695f5985e9cbd7a5206908fe6d2ea7e77865e9 (diff) | |
download | CMake-bd38749fd43c1d550f7c45e96a97cddb90c29437.zip CMake-bd38749fd43c1d550f7c45e96a97cddb90c29437.tar.gz CMake-bd38749fd43c1d550f7c45e96a97cddb90c29437.tar.bz2 |
ctest: allow test output to add labels
Parse test output for <CTestLabel>...</CTestLabel>.
If found, add this value to the list of labels associated with this test.
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestRunTest.cxx | 17 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 2 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.h | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index a892113..50072c5 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestRunTest.h" +#include <algorithm> #include <chrono> #include <cstddef> // IWYU pragma: keep #include <cstdint> @@ -44,7 +45,9 @@ void cmCTestRunTest::CheckOutput(std::string const& line) // Check for special CTest XML tags in this line of output. // If any are found, this line is excluded from ProcessOutput. if (!line.empty() && line.find("<CTest") != std::string::npos) { + bool ctest_tag_found = false; if (this->TestHandler->CustomCompletionStatusRegex.find(line)) { + ctest_tag_found = true; this->TestResult.CustomCompletionStatus = this->TestHandler->CustomCompletionStatusRegex.match(1); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, @@ -52,6 +55,20 @@ void cmCTestRunTest::CheckOutput(std::string const& line) << "Test Details changed to '" << this->TestResult.CustomCompletionStatus << "'" << std::endl); + } else if (this->TestHandler->CustomLabelRegex.find(line)) { + ctest_tag_found = true; + auto label = this->TestHandler->CustomLabelRegex.match(1); + auto& labels = this->TestProperties->Labels; + if (std::find(labels.begin(), labels.end(), label) == labels.end()) { + labels.push_back(label); + std::sort(labels.begin(), labels.end()); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + this->GetIndex() + << ": " + << "Test Label added: '" << label << "'" << std::endl); + } + } + if (ctest_tag_found) { return; } } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 730ec0f..aeaf696 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -312,6 +312,8 @@ cmCTestTestHandler::cmCTestTestHandler() // regex to detect <CTestDetails>...</CTestDetails> this->CustomCompletionStatusRegex.compile( "<CTestDetails>(.*)</CTestDetails>"); + // regex to detect <CTestLabel>...</CTestLabel> + this->CustomLabelRegex.compile("<CTestLabel>(.*)</CTestLabel>"); } void cmCTestTestHandler::Initialize() diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index bd51738..cc19984 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -360,6 +360,7 @@ private: size_t TotalNumberOfTests; cmsys::RegularExpression DartStuff; cmsys::RegularExpression CustomCompletionStatusRegex; + cmsys::RegularExpression CustomLabelRegex; std::ostream* LogFile; |