summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestBuildHandler.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-08-26 14:32:37 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-08-26 14:33:08 (GMT)
commit7d89c5bf77ab00273d30a7e88a9ea85d55e34854 (patch)
tree1ce5c67753a8c56a706236a2bd287ceead2d2619 /Source/CTest/cmCTestBuildHandler.cxx
parentf5a7ae0c4bcfa90fb530d69f9277290c5f947db2 (diff)
parent207926795971d260d602390fbd70e3cb78b4deb3 (diff)
downloadCMake-7d89c5bf77ab00273d30a7e88a9ea85d55e34854.zip
CMake-7d89c5bf77ab00273d30a7e88a9ea85d55e34854.tar.gz
CMake-7d89c5bf77ab00273d30a7e88a9ea85d55e34854.tar.bz2
Merge topic 'warnings_skip_color'
2079267959 ctest_build: ignore ANSI color Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3702
Diffstat (limited to 'Source/CTest/cmCTestBuildHandler.cxx')
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx27
1 files changed, 18 insertions, 9 deletions
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index 8d1f76b..147286e 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -10,6 +10,7 @@
#include "cmMakefile.h"
#include "cmProcessOutput.h"
#include "cmStringAlgorithms.h"
+#include "cmStringReplaceHelper.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
@@ -408,6 +409,9 @@ int cmCTestBuildHandler::ProcessHandler()
// Remember start build time
this->StartBuild = this->CTest->CurrentTime();
this->StartBuildTime = std::chrono::system_clock::now();
+
+ cmStringReplaceHelper colorRemover("\x1b\\[[0-9;]*m", "", nullptr);
+ this->ColorRemover = &colorRemover;
int retVal = 0;
int res = cmsysProcess_State_Exited;
if (!this->CTest->GetShowOnly()) {
@@ -1070,7 +1074,12 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
return b_REGULAR_LINE;
}
- cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" << std::endl,
+ // Ignore ANSI color codes when checking for errors and warnings.
+ std::string input(data);
+ std::string line;
+ this->ColorRemover->Replace(input, line);
+
+ cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << line << "]" << std::endl,
this->Quiet);
int warningLine = 0;
@@ -1082,10 +1091,10 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
// Errors
int wrxCnt = 0;
for (cmsys::RegularExpression& rx : this->ErrorMatchRegex) {
- if (rx.find(data)) {
+ if (rx.find(line.c_str())) {
errorLine = 1;
cmCTestOptionalLog(this->CTest, DEBUG,
- " Error Line: " << data << " (matches: "
+ " Error Line: " << line << " (matches: "
<< this->CustomErrorMatches[wrxCnt]
<< ")" << std::endl,
this->Quiet);
@@ -1096,11 +1105,11 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
// Error exceptions
wrxCnt = 0;
for (cmsys::RegularExpression& rx : this->ErrorExceptionRegex) {
- if (rx.find(data)) {
+ if (rx.find(line.c_str())) {
errorLine = 0;
cmCTestOptionalLog(this->CTest, DEBUG,
" Not an error Line: "
- << data << " (matches: "
+ << line << " (matches: "
<< this->CustomErrorExceptions[wrxCnt] << ")"
<< std::endl,
this->Quiet);
@@ -1113,11 +1122,11 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
// Warnings
int wrxCnt = 0;
for (cmsys::RegularExpression& rx : this->WarningMatchRegex) {
- if (rx.find(data)) {
+ if (rx.find(line.c_str())) {
warningLine = 1;
cmCTestOptionalLog(this->CTest, DEBUG,
" Warning Line: "
- << data << " (matches: "
+ << line << " (matches: "
<< this->CustomWarningMatches[wrxCnt] << ")"
<< std::endl,
this->Quiet);
@@ -1129,11 +1138,11 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
wrxCnt = 0;
// Warning exceptions
for (cmsys::RegularExpression& rx : this->WarningExceptionRegex) {
- if (rx.find(data)) {
+ if (rx.find(line.c_str())) {
warningLine = 0;
cmCTestOptionalLog(this->CTest, DEBUG,
" Not a warning Line: "
- << data << " (matches: "
+ << line << " (matches: "
<< this->CustomWarningExceptions[wrxCnt] << ")"
<< std::endl,
this->Quiet);