ENH: Better handle interleved error/output

This commit is contained in:
Andy Cedilnik 2006-01-27 13:46:33 -05:00
parent 9f625beab6
commit 04c705bc01
2 changed files with 28 additions and 18 deletions

View File

@ -107,17 +107,17 @@ static const char* cmCTestWarningMatches[] = {
"^cc[^C]*CC: WARNING File = ([^,]+), Line = ([0-9]+)", "^cc[^C]*CC: WARNING File = ([^,]+), Line = ([0-9]+)",
"^ld([^:])*:([ \\t])*WARNING([^:])*:", "^ld([^:])*:([ \\t])*WARNING([^:])*:",
"([^:]+): warning ([0-9]+):", "([^:]+): warning ([0-9]+):",
"^\"[^\"]+\", line [0-9]+: [Ww]arning", "^\"[^\"]+\", line [0-9]+: [Ww](arning|arnung)",
"([^:]+): warning[ \\t]*[0-9]+[ \\t]*:", "([^:]+): warning[ \\t]*[0-9]+[ \\t]*:",
"^Warning ([0-9]+):", "^(Warning|Warnung) ([0-9]+):",
"^Warning ", "^(Warning|Warnung) ",
"WARNING: ", "WARNING: ",
"([^ :]+) : warning", "([^ :]+) : warning",
"([^:]+): warning", "([^:]+): warning",
"\", line [0-9]+\\.[0-9]+: [0-9]+-[0-9]+ \\(W\\)", "\", line [0-9]+\\.[0-9]+: [0-9]+-[0-9]+ \\(W\\)",
"^cxx: Warning:", "^cxx: Warning:",
".*file: .* has no symbols", ".*file: .* has no symbols",
"([^ :]+):([0-9]+): Warning", "([^ :]+):([0-9]+): (Warning|Warnung)",
"\\([0-9]*\\): remark #[0-9]*", "\\([0-9]*\\): remark #[0-9]*",
"\".*\", line [0-9]+: remark\\([0-9]*\\):", "\".*\", line [0-9]+: remark\\([0-9]*\\):",
"cc-[0-9]* CC: REMARK File = .*, Line = [0-9]*", "cc-[0-9]* CC: REMARK File = .*, Line = [0-9]*",
@ -192,7 +192,7 @@ void cmCTestBuildHandler::Initialize()
m_WarningMatchRegex.clear(); m_WarningMatchRegex.clear();
m_WarningExceptionRegex.clear(); m_WarningExceptionRegex.clear();
m_BuildProcessingQueue.clear(); m_BuildProcessingQueue.clear();
m_BuildProcessingQueueLocation = m_BuildProcessingQueue.end(); m_BuildProcessingErrorQueue.clear();
m_BuildOutputLogSize = 0; m_BuildOutputLogSize = 0;
m_CurrentProcessingLine.clear(); m_CurrentProcessingLine.clear();
@ -593,7 +593,8 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
m_ErrorQuotaReached = false; m_ErrorQuotaReached = false;
// For every chunk of data // For every chunk of data
while(cmsysProcess_WaitForData(cp, &data, &length, 0)) int res;
while((res = cmsysProcess_WaitForData(cp, &data, &length, 0)))
{ {
// Replace '\0' with '\n', since '\0' does not really make sense. This is // Replace '\0' with '\n', since '\0' does not really make sense. This is
// for Visual Studio output // for Visual Studio output
@ -606,10 +607,18 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
} }
// Process the chunk of data // Process the chunk of data
this->ProcessBuffer(data, length, tick, tick_len, ofs); if ( res == cmsysProcess_Pipe_STDERR )
{
this->ProcessBuffer(data, length, tick, tick_len, ofs, &m_BuildProcessingErrorQueue);
}
else
{
this->ProcessBuffer(data, length, tick, tick_len, ofs, &m_BuildProcessingQueue);
}
} }
this->ProcessBuffer(0, 0, tick, tick_len, ofs); this->ProcessBuffer(0, 0, tick, tick_len, ofs, &m_BuildProcessingQueue);
this->ProcessBuffer(0, 0, tick, tick_len, ofs, &m_BuildProcessingErrorQueue);
cmCTestLog(m_CTest, OUTPUT, " Size of output: " cmCTestLog(m_CTest, OUTPUT, " Size of output: "
<< int(m_BuildOutputLogSize / 1024.0) << "K" << std::endl); << int(m_BuildOutputLogSize / 1024.0) << "K" << std::endl);
@ -658,14 +667,14 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& tick, size_t tick_len, void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& tick, size_t tick_len,
std::ofstream& ofs) std::ofstream& ofs, t_BuildProcessingQueueType* queue)
{ {
#undef cerr #undef cerr
const std::string::size_type tick_line_len = 50; const std::string::size_type tick_line_len = 50;
const char* ptr; const char* ptr;
for ( ptr = data; ptr < data+length; ptr ++ ) for ( ptr = data; ptr < data+length; ptr ++ )
{ {
m_BuildProcessingQueue.push_back(*ptr); queue->push_back(*ptr);
} }
m_BuildOutputLogSize += length; m_BuildOutputLogSize += length;
@ -674,8 +683,8 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& ti
{ {
// Find the end of line // Find the end of line
t_BuildProcessingQueueType::iterator it; t_BuildProcessingQueueType::iterator it;
for ( it = m_BuildProcessingQueue.begin(); for ( it = queue->begin();
it != m_BuildProcessingQueue.end(); it != queue->end();
++ it ) ++ it )
{ {
if ( *it == '\n' ) if ( *it == '\n' )
@ -695,12 +704,12 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& ti
} }
// If the end of line was found // If the end of line was found
if ( it != m_BuildProcessingQueue.end() ) if ( it != queue->end() )
{ {
// Create a contiguous array for the line // Create a contiguous array for the line
m_CurrentProcessingLine.clear(); m_CurrentProcessingLine.clear();
t_BuildProcessingQueueType::iterator cit; t_BuildProcessingQueueType::iterator cit;
for ( cit = m_BuildProcessingQueue.begin(); cit != it; ++cit ) for ( cit = queue->begin(); cit != it; ++cit )
{ {
m_CurrentProcessingLine.push_back(*cit); m_CurrentProcessingLine.push_back(*cit);
} }
@ -711,7 +720,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, size_t& ti
int lineType = this->ProcessSingleLine(line); int lineType = this->ProcessSingleLine(line);
// Erase the line from the queue // Erase the line from the queue
m_BuildProcessingQueue.erase(m_BuildProcessingQueue.begin(), it+1); queue->erase(queue->begin(), it+1);
// Depending on the line type, produce error or warning, or nothing // Depending on the line type, produce error or warning, or nothing
cmCTestBuildErrorWarning errorwarning; cmCTestBuildErrorWarning errorwarning;

View File

@ -103,13 +103,14 @@ private:
std::vector<cmsys::RegularExpression> m_WarningMatchRegex; std::vector<cmsys::RegularExpression> m_WarningMatchRegex;
std::vector<cmsys::RegularExpression> m_WarningExceptionRegex; std::vector<cmsys::RegularExpression> m_WarningExceptionRegex;
typedef std::deque<char> t_BuildProcessingQueueType;
void ProcessBuffer(const char* data, int length, size_t& tick, size_t tick_len, void ProcessBuffer(const char* data, int length, size_t& tick, size_t tick_len,
std::ofstream& ofs); std::ofstream& ofs, t_BuildProcessingQueueType* queue);
int ProcessSingleLine(const char* data); int ProcessSingleLine(const char* data);
typedef std::deque<char> t_BuildProcessingQueueType;
t_BuildProcessingQueueType m_BuildProcessingQueue; t_BuildProcessingQueueType m_BuildProcessingQueue;
t_BuildProcessingQueueType::iterator m_BuildProcessingQueueLocation; t_BuildProcessingQueueType m_BuildProcessingErrorQueue;
size_t m_BuildOutputLogSize; size_t m_BuildOutputLogSize;
std::vector<char> m_CurrentProcessingLine; std::vector<char> m_CurrentProcessingLine;