ENH: Improve performance of MakeXMLSafe, improve performance of reading custom ctest files, and remove error when running ctest on directory without DartConfiguration.tcl
This commit is contained in:
parent
26a70a2e37
commit
baf5601acb
@ -139,45 +139,47 @@ std::string cmCTest::CurrentTime()
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
std::string cmCTest::MakeXMLSafe(const std::string& str)
|
std::string cmCTest::MakeXMLSafe(const std::string& str)
|
||||||
{
|
{
|
||||||
cmOStringStream ost;
|
std::vector<char> result;
|
||||||
// By uncommenting the lcnt code, it will put newline every 120 characters
|
result.reserve(500);
|
||||||
//int lcnt = 0;
|
const char* pos = str.c_str();
|
||||||
for (std::string::size_type pos = 0; pos < str.size(); pos ++ )
|
for ( ;*pos; ++pos)
|
||||||
{
|
{
|
||||||
unsigned char ch = str[pos];
|
char ch = *pos;
|
||||||
if ( ch == '\r' )
|
if ( (ch > 126 || ch < 32) && ch != 9 && ch != 10 && ch != 13 && ch != '\r' )
|
||||||
{
|
|
||||||
// Ignore extra CR characters.
|
|
||||||
}
|
|
||||||
else if ( (ch > 126 || ch < 32) && ch != 9 && ch != 10 && ch != 13 )
|
|
||||||
{
|
{
|
||||||
char buffer[33];
|
char buffer[33];
|
||||||
sprintf(buffer, "<%d>", (int)ch);
|
sprintf(buffer, "<%d>", (int)ch);
|
||||||
//sprintf(buffer, "&#x%0x;", (unsigned int)ch);
|
//sprintf(buffer, "&#x%0x;", (unsigned int)ch);
|
||||||
ost << buffer;
|
result.insert(result.end(), buffer, buffer+strlen(buffer));
|
||||||
//lcnt += 4;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const char* const encodedChars[] = {
|
||||||
|
"&",
|
||||||
|
"<",
|
||||||
|
">"
|
||||||
|
};
|
||||||
switch ( ch )
|
switch ( ch )
|
||||||
{
|
{
|
||||||
case '&': ost << "&"; break;
|
case '&':
|
||||||
case '<': ost << "<"; break;
|
result.insert(result.end(), encodedChars[0], encodedChars[0]+5);
|
||||||
case '>': ost << ">"; break;
|
|
||||||
case '\n': ost << "\n";
|
|
||||||
//lcnt = 0;
|
|
||||||
break;
|
break;
|
||||||
default: ost << ch;
|
case '<':
|
||||||
|
result.insert(result.end(), encodedChars[1], encodedChars[1]+4);
|
||||||
|
break;
|
||||||
|
case '>':
|
||||||
|
result.insert(result.end(), encodedChars[2], encodedChars[2]+4);
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
result.push_back('\n');
|
||||||
|
break;
|
||||||
|
case '\r': break; // Ignore \r
|
||||||
|
default:
|
||||||
|
result.push_back(ch);
|
||||||
}
|
}
|
||||||
//lcnt ++;
|
|
||||||
}
|
}
|
||||||
//if ( lcnt > 120 )
|
|
||||||
// {
|
|
||||||
// ost << "\n";
|
|
||||||
// lcnt = 0;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
return ost.str();
|
return std::string(&*result.begin(), result.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
@ -473,49 +475,56 @@ bool cmCTest::UpdateCTestConfiguration()
|
|||||||
}
|
}
|
||||||
if ( !cmSystemTools::FileExists(fileName.c_str()) )
|
if ( !cmSystemTools::FileExists(fileName.c_str()) )
|
||||||
{
|
{
|
||||||
cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName.c_str() << std::endl);
|
// No need to exit if we are not producing XML
|
||||||
return false;
|
if ( m_ProduceXML )
|
||||||
}
|
|
||||||
// parse the dart test file
|
|
||||||
std::ifstream fin(fileName.c_str());
|
|
||||||
if(!fin)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
char buffer[1024];
|
|
||||||
while ( fin )
|
|
||||||
{
|
|
||||||
buffer[0] = 0;
|
|
||||||
fin.getline(buffer, 1023);
|
|
||||||
buffer[1023] = 0;
|
|
||||||
std::string line = cmCTest::CleanString(buffer);
|
|
||||||
if(line.size() == 0)
|
|
||||||
{
|
{
|
||||||
continue;
|
cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName.c_str() << std::endl);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
while ( fin && (line[line.size()-1] == '\\') )
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// parse the dart test file
|
||||||
|
std::ifstream fin(fileName.c_str());
|
||||||
|
if(!fin)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char buffer[1024];
|
||||||
|
while ( fin )
|
||||||
{
|
{
|
||||||
line = line.substr(0, line.size()-1);
|
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
fin.getline(buffer, 1023);
|
fin.getline(buffer, 1023);
|
||||||
buffer[1023] = 0;
|
buffer[1023] = 0;
|
||||||
line += cmCTest::CleanString(buffer);
|
std::string line = cmCTest::CleanString(buffer);
|
||||||
|
if(line.size() == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
while ( fin && (line[line.size()-1] == '\\') )
|
||||||
|
{
|
||||||
|
line = line.substr(0, line.size()-1);
|
||||||
|
buffer[0] = 0;
|
||||||
|
fin.getline(buffer, 1023);
|
||||||
|
buffer[1023] = 0;
|
||||||
|
line += cmCTest::CleanString(buffer);
|
||||||
|
}
|
||||||
|
if ( line[0] == '#' )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::string::size_type cpos = line.find_first_of(":");
|
||||||
|
if ( cpos == line.npos )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::string key = line.substr(0, cpos);
|
||||||
|
std::string value = cmCTest::CleanString(line.substr(cpos+1, line.npos));
|
||||||
|
m_CTestConfiguration[key] = value;
|
||||||
}
|
}
|
||||||
if ( line[0] == '#' )
|
fin.close();
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::string::size_type cpos = line.find_first_of(":");
|
|
||||||
if ( cpos == line.npos )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::string key = line.substr(0, cpos);
|
|
||||||
std::string value = cmCTest::CleanString(line.substr(cpos+1, line.npos));
|
|
||||||
m_CTestConfiguration[key] = value;
|
|
||||||
}
|
}
|
||||||
fin.close();
|
|
||||||
if ( m_ProduceXML )
|
if ( m_ProduceXML )
|
||||||
{
|
{
|
||||||
m_TimeOut = atoi(m_CTestConfiguration["TimeOut"].c_str());
|
m_TimeOut = atoi(m_CTestConfiguration["TimeOut"].c_str());
|
||||||
@ -1699,7 +1708,6 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir)
|
|||||||
{
|
{
|
||||||
tm_VectorOfStrings dirs;
|
tm_VectorOfStrings dirs;
|
||||||
tm_VectorOfStrings ndirs;
|
tm_VectorOfStrings ndirs;
|
||||||
dirs.push_back(dir);
|
|
||||||
cmake cm;
|
cmake cm;
|
||||||
cmGlobalGenerator gg;
|
cmGlobalGenerator gg;
|
||||||
gg.SetCMakeInstance(&cm);
|
gg.SetCMakeInstance(&cm);
|
||||||
@ -1707,20 +1715,22 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir)
|
|||||||
lg->SetGlobalGenerator(&gg);
|
lg->SetGlobalGenerator(&gg);
|
||||||
cmMakefile *mf = lg->GetMakefile();
|
cmMakefile *mf = lg->GetMakefile();
|
||||||
|
|
||||||
while ( dirs.size() > 0 )
|
std::string rexpr = dir;
|
||||||
|
rexpr += "/*/CTestCustom.ctest";
|
||||||
|
cmGlob gl;
|
||||||
|
gl.RecurseOn();
|
||||||
|
gl.FindFiles(rexpr);
|
||||||
|
std::vector<std::string>& files = gl.GetFiles();
|
||||||
|
std::vector<std::string>::iterator fileIt;
|
||||||
|
for ( fileIt = files.begin(); fileIt != files.end();
|
||||||
|
++ fileIt )
|
||||||
{
|
{
|
||||||
tm_VectorOfStrings::iterator cdir = dirs.end()-1;
|
cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: " << fileIt->c_str() << std::endl);
|
||||||
std::string rexpr = *cdir + "/*";
|
if ( !lg->GetMakefile()->ReadListFile(0, fileIt->c_str()) ||
|
||||||
std::string fname = *cdir + "/CTestCustom.ctest";
|
cmSystemTools::GetErrorOccuredFlag() )
|
||||||
if ( cmSystemTools::FileExists(fname.c_str()) &&
|
|
||||||
(!lg->GetMakefile()->ReadListFile(0, fname.c_str()) ||
|
|
||||||
cmSystemTools::GetErrorOccuredFlag() ) )
|
|
||||||
{
|
{
|
||||||
cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration" << std::endl);
|
cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration: " << fileIt->c_str() << std::endl);
|
||||||
}
|
}
|
||||||
dirs.erase(dirs.end()-1, dirs.end());
|
|
||||||
cmSystemTools::SimpleGlob(rexpr, ndirs, -1);
|
|
||||||
dirs.insert(dirs.end(), ndirs.begin(), ndirs.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmCTest::t_TestingHandlers::iterator it;
|
cmCTest::t_TestingHandlers::iterator it;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user