ENH: Add support for output reguilar expression

This commit is contained in:
Andy Cedilnik 2005-11-08 17:59:20 -05:00
parent eccc4779e4
commit 34e7834451
3 changed files with 87 additions and 2 deletions

View File

@ -751,7 +751,39 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
if ( !m_CTest->GetShowOnly() )
{
bool testFailed = false;
if (res == cmsysProcess_State_Exited && retVal == 0)
std::vector<cmsys::RegularExpression>::iterator passIt;
bool forceFail = false;
if ( it->m_RequiredRegularExpressions.size() > 0 )
{
bool found = false;
for ( passIt = it->m_RequiredRegularExpressions.begin();
passIt != it->m_RequiredRegularExpressions.end();
++ passIt )
{
if ( passIt->find(output.c_str()) )
{
found = true;
}
}
if ( !found )
{
forceFail = true;
}
}
if ( it->m_ErrorRegularExpressions.size() > 0 )
{
for ( passIt = it->m_ErrorRegularExpressions.begin();
passIt != it->m_ErrorRegularExpressions.end();
++ passIt )
{
if ( passIt->find(output.c_str()) )
{
forceFail = true;
}
}
}
if (res == cmsysProcess_State_Exited && retVal == 0 && !forceFail)
{
cmCTestLog(m_CTest, HANDLER_OUTPUT, " Passed");
if ( it->m_WillFail )
@ -769,6 +801,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
else
{
testFailed = true;
cres.m_Status = cmCTestTestHandler::FAILED;
if ( res == cmsysProcess_State_Expired )
{
@ -809,6 +842,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
}
else
{
// Force fail will also be here?
cmCTestLog(m_CTest, HANDLER_OUTPUT, "***Failed");
if ( it->m_WillFail )
{
@ -1524,6 +1558,26 @@ bool cmCTestTestHandler::SetTestsProperties(const std::vector<std::string>& args
{
rtit->m_WillFail = cmSystemTools::IsOn(val.c_str());
}
if ( key == "ERROR_REGULAR_EXPRESSION" )
{
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val.c_str(), lval);
std::vector<std::string>::iterator crit;
for ( crit = lval.begin(); crit != lval.end(); ++ crit )
{
rtit->m_ErrorRegularExpressions.push_back(cmsys::RegularExpression(crit->c_str()));
}
}
if ( key == "REQUIRED_REGULAR_EXPRESSION" )
{
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val.c_str(), lval);
std::vector<std::string>::iterator crit;
for ( crit = lval.begin(); crit != lval.end(); ++ crit )
{
rtit->m_RequiredRegularExpressions.push_back(cmsys::RegularExpression(crit->c_str()));
}
}
}
}
}

View File

@ -95,6 +95,8 @@ protected:
cmStdString m_Name;
cmStdString m_Directory;
std::vector<std::string> m_Args;
std::vector<cmsys::RegularExpression> m_ErrorRegularExpressions;
std::vector<cmsys::RegularExpression> m_RequiredRegularExpressions;
bool m_IsInBasedOnREOptions;
bool m_WillFail;
};

View File

@ -184,7 +184,36 @@ void cmLocalGenerator::GenerateTestFiles()
fout << "SET_TESTS_PROPERTIES(" << test->GetName() << " PROPERTIES ";
for ( pit = mpit->begin(); pit != mpit->end(); ++ pit )
{
fout << " " << pit->first.c_str() << " \"" << pit->second.c_str() << "\"";
fout << " " << pit->first.c_str() << " \"";
const char* value = pit->second.c_str();
for ( ; *value; ++ value )
{
switch ( *value )
{
case '\\':
case '"':
case ' ':
case '#':
case '(':
case ')':
case '$':
case '^':
fout << "\\" << *value;
break;
case '\t':
fout << "\\t";
break;
case '\n':
fout << "\\n";
break;
case '\r':
fout << "\\r";
break;
default:
fout << *value;
}
}
fout << "\"";
}
fout << ")" << std::endl;
}