diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 6c9b5d846..0385cd7aa 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -751,7 +751,39 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, if ( !m_CTest->GetShowOnly() ) { bool testFailed = false; - if (res == cmsysProcess_State_Exited && retVal == 0) + std::vector::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 &passed, else { testFailed = true; + cres.m_Status = cmCTestTestHandler::FAILED; if ( res == cmsysProcess_State_Expired ) { @@ -809,6 +842,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &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& args { rtit->m_WillFail = cmSystemTools::IsOn(val.c_str()); } + if ( key == "ERROR_REGULAR_EXPRESSION" ) + { + std::vector lval; + cmSystemTools::ExpandListArgument(val.c_str(), lval); + std::vector::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 lval; + cmSystemTools::ExpandListArgument(val.c_str(), lval); + std::vector::iterator crit; + for ( crit = lval.begin(); crit != lval.end(); ++ crit ) + { + rtit->m_RequiredRegularExpressions.push_back(cmsys::RegularExpression(crit->c_str())); + } + } } } } diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 7e9043fb2..fc0e23099 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -95,6 +95,8 @@ protected: cmStdString m_Name; cmStdString m_Directory; std::vector m_Args; + std::vector m_ErrorRegularExpressions; + std::vector m_RequiredRegularExpressions; bool m_IsInBasedOnREOptions; bool m_WillFail; }; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 1aa06867c..f48f760f3 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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; }