summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2009-01-14 18:01:38 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2009-01-14 18:01:38 (GMT)
commit82c3afcf6f78833e55bc6140799b5809a4527f03 (patch)
treeb256f9c50d664798ebbb8f8ab8c94d90acf11cec /Source/CTest
parente92d99d05c4edf1a7aae5eee4c66432f9e01d04f (diff)
downloadCMake-82c3afcf6f78833e55bc6140799b5809a4527f03.zip
CMake-82c3afcf6f78833e55bc6140799b5809a4527f03.tar.gz
CMake-82c3afcf6f78833e55bc6140799b5809a4527f03.tar.bz2
ENH: allow ctest_build to return error and warning counts
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestBuildCommand.cxx28
-rw-r--r--Source/CTest/cmCTestBuildCommand.h15
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx8
-rw-r--r--Source/CTest/cmCTestBuildHandler.h2
-rw-r--r--Source/CTest/cmProcess.cxx2
5 files changed, 49 insertions, 6 deletions
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx
index 58c3efd..a98f621 100644
--- a/Source/CTest/cmCTestBuildCommand.cxx
+++ b/Source/CTest/cmCTestBuildCommand.cxx
@@ -18,6 +18,7 @@
#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
+#include "cmCTestBuildHandler.h"
#include "cmake.h"
#include "cmGlobalGenerator.h"
@@ -26,6 +27,10 @@
cmCTestBuildCommand::cmCTestBuildCommand()
{
this->GlobalGenerator = 0;
+ this->Arguments[ctb_NUMBER_ERRORS] = "NUMBER_ERRORS";
+ this->Arguments[ctb_NUMBER_WARNINGS] = "NUMBER_WARNINGS";
+ this->Arguments[ctb_LAST] = 0;
+ this->Last = ctb_LAST;
}
//----------------------------------------------------------------------------
@@ -48,7 +53,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
this->SetError("internal CTest error. Cannot instantiate build handler");
return 0;
}
-
+ this->Handler = (cmCTestBuildHandler*)handler;
const char* ctestBuildCommand
= this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
if ( ctestBuildCommand && *ctestBuildCommand )
@@ -132,3 +137,24 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
}
+bool cmCTestBuildCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus &status)
+{
+ bool ret = cmCTestHandlerCommand::InitialPass(args, status);
+ if ( this->Values[ctb_NUMBER_ERRORS] && *this->Values[ctb_NUMBER_ERRORS])
+ {
+ cmOStringStream str;
+ str << this->Handler->GetTotalErrors();
+ this->Makefile->AddDefinition(
+ this->Values[ctb_NUMBER_ERRORS], str.str().c_str());
+ }
+ if ( this->Values[ctb_NUMBER_WARNINGS]
+ && *this->Values[ctb_NUMBER_WARNINGS])
+ {
+ cmOStringStream str;
+ str << this->Handler->GetTotalWarnings();
+ this->Makefile->AddDefinition(
+ this->Values[ctb_NUMBER_WARNINGS], str.str().c_str());
+ }
+ return ret;
+}
diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h
index 4853a66..a961388 100644
--- a/Source/CTest/cmCTestBuildCommand.h
+++ b/Source/CTest/cmCTestBuildCommand.h
@@ -20,6 +20,7 @@
#include "cmCTestHandlerCommand.h"
class cmGlobalGenerator;
+class cmCTestBuildHandler;
/** \class cmCTestBuild
* \brief Run a ctest script
@@ -56,14 +57,16 @@ public:
{
return "Builds the repository.";
}
-
+ virtual bool InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus &status);
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
- " ctest_build([BUILD build_dir] [RETURN_VALUE res])\n"
+ " ctest_build([BUILD build_dir] [RETURN_VALUE res] "
+ " [NUMBER_ERRORS val] [NUMBER_WARNINGS val])\n"
"Builds the given build directory and stores results in Build.xml.";
}
@@ -72,6 +75,14 @@ public:
cmGlobalGenerator* GlobalGenerator;
protected:
+ cmCTestBuildHandler* Handler;
+ enum {
+ ctb_BUILD = ct_LAST,
+ ctb_NUMBER_ERRORS,
+ ctb_NUMBER_WARNINGS,
+ ctb_LAST
+ };
+
cmCTestGenericHandler* InitializeHandler();
};
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index ca7061b..a730981 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -475,7 +475,7 @@ int cmCTestBuildHandler::ProcessHandler()
}
this->GenerateDartBuildOutput(
xofs, this->ErrorsAndWarnings, elapsed_build_time);
- return 0;
+ return res;
}
//----------------------------------------------------------------------
@@ -724,6 +724,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
errorwarning.Error = false;
this->ErrorsAndWarnings.push_back(errorwarning);
this->TotalWarnings ++;
+ return *retVal; // return the program return value
}
}
}
@@ -734,11 +735,13 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
*retVal = cmsysProcess_GetExitException(cp);
cmCTestLog(this->CTest, WARNING, "There was an exception: " << *retVal
<< std::endl);
+ return *retVal;
}
}
else if(result == cmsysProcess_State_Expired)
{
cmCTestLog(this->CTest, WARNING, "There was a timeout" << std::endl);
+ return -1;
}
else if(result == cmsysProcess_State_Error)
{
@@ -754,11 +757,12 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
this->TotalErrors ++;
cmCTestLog(this->CTest, ERROR_MESSAGE, "There was an error: "
<< cmsysProcess_GetErrorString(cp) << std::endl);
+ return -1;
}
cmsysProcess_Delete(cp);
- return result;
+ return 0;
}
//######################################################################
diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h
index 73d5a5a..cdc1b68 100644
--- a/Source/CTest/cmCTestBuildHandler.h
+++ b/Source/CTest/cmCTestBuildHandler.h
@@ -49,6 +49,8 @@ public:
*/
virtual void Initialize();
+ int GetTotalErrors() { return this->TotalErrors;}
+ int GetTotalWarnings() { return this->TotalWarnings;}
private:
//! Run command specialized for make and configure. Returns process status
// and retVal is return value or exception.
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 75db654..37c6a17 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -213,7 +213,7 @@ bool cmProcess::IsRunning()
cmsysProcess_WaitForExit(this->Process, 0);
this->ExitValue = cmsysProcess_GetExitValue(this->Process);
this->TotalTime = cmSystemTools::GetTime() - this->StartTime;
-// std::cerr << "Time to run: " << this->TotalTime << "\n";
+ std::cerr << "Time to run: " << this->TotalTime << "\n";
return false;
}