From 3b73cdc89fdcdbbf1708bc6a2312a00bd2325711 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 24 Feb 2009 17:23:51 -0500 Subject: ENH: add a CDash measured value showing the reason for passed and failed tests based on regular expressions --- Source/CTest/cmCTestMultiProcessHandler.cxx | 4 ++++ Source/CTest/cmCTestTestHandler.cxx | 32 +++++++++++++++++++++-------- Source/CTest/cmCTestTestHandler.h | 1 + 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 56800e9..e231c33 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -240,6 +240,10 @@ bool cmCTestMultiProcessHandler::CheckOutput() void cmCTestMultiProcessHandler::EndTest(cmProcess* p) { + // Should have a way of getting this stuff from the + // launched ctest, maybe a temp file or some extra xml + // stuff in the stdout + // Need things like Reason and ExecutionTime, Path, etc. int test = p->GetId(); int exitVal = p->GetExitValue(); cmCTestTestHandler::cmCTestTestResult cres; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 7f3b995..7cd2839 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -799,22 +799,23 @@ void cmCTestTestHandler::ProcessOneTest(cmCTestTestProperties *it, if ( passIt->first.find(output.c_str()) ) { found = true; + reason = "Required regular expression found."; } } if ( !found ) { reason = "Required regular expression not found."; - reason += "Regex=["; - for ( passIt = it->RequiredRegularExpressions.begin(); + forceFail = true; + } + reason += "Regex=["; + for ( passIt = it->RequiredRegularExpressions.begin(); passIt != it->RequiredRegularExpressions.end(); ++ passIt ) - { - reason += passIt->second; - reason += "\n"; - } - reason += "]"; - forceFail = true; + { + reason += passIt->second; + reason += "\n"; } + reason += "]"; } if ( it->ErrorRegularExpressions.size() > 0 ) { @@ -947,7 +948,7 @@ void cmCTestTestHandler::ProcessOneTest(cmCTestTestProperties *it, (this->CustomMaximumFailedTestOutputSize)); } } - + cres.Reason = reason; cres.Output = output; cres.ReturnValue = retVal; cres.CompletionStatus = "Completed"; @@ -1585,6 +1586,19 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) << "name=\"Execution Time\">" << result->ExecutionTime << "\n"; + if(result->Reason.size()) + { + const char* reasonType = "Pass Reason"; + if(result->Status != cmCTestTestHandler::COMPLETED && + result->Status != cmCTestTestHandler::NOT_RUN) + { + reasonType = "Fail Reason"; + } + os << "\t\t\t" + << cmXMLSafe(result->Reason) + << "\n"; + } os << "\t\t\t" diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index ab3d052..e5ee5dc 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -102,6 +102,7 @@ public: { std::string Name; std::string Path; + std::string Reason; std::string FullCommandLine; double ExecutionTime; int ReturnValue; -- cgit v0.12