More cleanups, fix prexontext and log number

This commit is contained in:
Andy Cedilnik 2002-10-14 09:30:10 -04:00
parent 461a3d2089
commit 066cea228b

View File

@ -460,11 +460,11 @@ int ctest::BuildDirectory()
{ {
std::cerr << "Error(s) when building project" << std::endl; std::cerr << "Error(s) when building project" << std::endl;
} }
// To do:
// Add parsing of output for errors and warnings.
cmCTestBuildErrorWarning cerw; // Parsing of output for errors and warnings.
int cc;
std::vector<cmStdString> lines;
cmSystemTools::Split(output.c_str(), lines);
std::ofstream ofs; std::ofstream ofs;
if ( this->OpenFile("Temporary", "LastBuild.log", ofs) ) if ( this->OpenFile("Temporary", "LastBuild.log", ofs) )
@ -472,16 +472,19 @@ int ctest::BuildDirectory()
ofs << output; ofs << output;
ofs.close(); ofs.close();
} }
else
{
std::cerr << "Cannot create LastBuild.log file" << std::endl;
}
std::vector<cmStdString> lines;
cmSystemTools::Split(output.c_str(), lines);
// Lines are marked: // Lines are marked:
// 0 - nothing // 0 - nothing
// 1 - error // 1 - error
// > 1 - warning // > 1 - warning
std::vector<int> markedLines(lines.size(), 0); std::vector<int> markedLines(lines.size(), 0);
cmCTestBuildErrorWarning cerw;
int cc;
// Errors // Errors
for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ ) for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ )
{ {
@ -508,6 +511,7 @@ int ctest::BuildDirectory()
} }
} }
} }
// Errors exceptions
for ( cc = 0; cmCTestErrorExceptions[cc]; cc ++ ) for ( cc = 0; cmCTestErrorExceptions[cc]; cc ++ )
{ {
cmRegularExpression re(cmCTestErrorExceptions[cc]); cmRegularExpression re(cmCTestErrorExceptions[cc]);
@ -523,6 +527,7 @@ int ctest::BuildDirectory()
} }
} }
} }
// Warning exceptions
for ( cc = 0; cmCTestWarningExceptions[cc]; cc ++ ) for ( cc = 0; cmCTestWarningExceptions[cc]; cc ++ )
{ {
cmRegularExpression re(cmCTestWarningExceptions[cc]); cmRegularExpression re(cmCTestWarningExceptions[cc]);
@ -560,13 +565,18 @@ int ctest::BuildDirectory()
} }
if ( found ) if ( found )
{ {
errorwarning.m_LogLine = static_cast<int>(kk); errorwarning.m_LogLine = static_cast<int>(kk+1);
errorwarning.m_Text = lines[kk]; errorwarning.m_Text = lines[kk];
errorwarning.m_PreContext = ""; errorwarning.m_PreContext = "";
errorwarning.m_PostContext = ""; errorwarning.m_PostContext = "";
std::vector<int>::size_type jj; std::vector<int>::size_type jj;
std::vector<int>::size_type ll = 0;
if ( kk > 6 )
{
ll = kk - 6;
}
for ( jj = kk; for ( jj = kk;
jj > 0 && jj > kk - 6 /* && markedLines[jj] == 0 */; jj > 0 && jj > ll /* && markedLines[jj] == 0 */;
jj -- ); jj -- );
for (; jj < kk; jj ++ ) for (; jj < kk; jj ++ )
{ {
@ -584,6 +594,7 @@ int ctest::BuildDirectory()
if( !this->OpenFile("", "Build.xml", ofs) ) if( !this->OpenFile("", "Build.xml", ofs) )
{ {
std::cerr << "Cannot create build XML file" << std::endl;
return 1; return 1;
} }
this->GenerateDartBuildOutput(ofs, errorsWarnings); this->GenerateDartBuildOutput(ofs, errorsWarnings);
@ -621,7 +632,6 @@ bool ctest::OpenFile(const std::string& path,
stream.open(filename.c_str()); stream.open(filename.c_str());
if( !stream ) if( !stream )
{ {
std::cerr << "Cannot create build XML file" << std::endl;
return false; return false;
} }
return true; return true;
@ -661,8 +671,8 @@ void ctest::GenerateDartBuildOutput(std::ostream& os,
os << "\t\t<SourceLineNumber>" << cm->m_LineNumber os << "\t\t<SourceLineNumber>" << cm->m_LineNumber
<< "</SourceLineNumber>" << std::endl; << "</SourceLineNumber>" << std::endl;
} }
os << "\t\t<PreContext>" << cm->m_PreContext << "\n</PreContext>\n" os << "\t\t<PreContext>" << cm->m_PreContext << "</PreContext>\n"
<< "\t\t<PostContext>" << cm->m_PostContext << "\n</PostContext>\n" << "\t\t<PostContext>" << cm->m_PostContext << "</PostContext>\n"
<< "\t\t<RepeatCount>0</RepeatCount>\n" << "\t\t<RepeatCount>0</RepeatCount>\n"
<< "</" << (cm->m_Error ? "Error" : "Warning") << ">\n\n" << "</" << (cm->m_Error ? "Error" : "Warning") << ">\n\n"
<< std::endl; << std::endl;
@ -884,28 +894,8 @@ int ctest::TestDirectory()
if ( m_DartMode ) if ( m_DartMode )
{ {
std::string testingDir = m_ToplevelPath + "/Testing/CDart"; std::ofstream ofs;
if ( cmSystemTools::FileExists(testingDir.c_str()) ) if( !this->OpenFile("", "Test.xml", ofs) )
{
if ( !cmSystemTools::FileIsDirectory(testingDir.c_str()) )
{
std::cerr << "File " << testingDir << " is in the place of the testing directory"
<< std::endl;
return 1;
}
}
else
{
if ( !cmSystemTools::MakeDirectory(testingDir.c_str()) )
{
std::cerr << "Cannot create directory " << testingDir
<< std::endl;
return 1;
}
}
std::string testxml = testingDir + "/Test.xml";
std::ofstream ofs(testxml.c_str());
if( !ofs )
{ {
std::cerr << "Cannot create testing XML file" << std::endl; std::cerr << "Cannot create testing XML file" << std::endl;
return 1; return 1;