From d9dc9b54a62c20be2cf42ce050780e1b924e412c Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Fri, 17 Jun 2005 13:04:56 -0400 Subject: [PATCH] ENH: Add superclass for all commands and handlers. Improve handlers to have initialization code, and start initializing ctest when start is invoked --- Source/CTest/cmCTestBuildAndTestHandler.cxx | 5 ++ Source/CTest/cmCTestBuildAndTestHandler.h | 3 ++ Source/CTest/cmCTestBuildHandler.cxx | 58 +++++++++++++++++++++ Source/CTest/cmCTestBuildHandler.h | 6 +++ Source/CTest/cmCTestConfigureHandler.cxx | 4 ++ Source/CTest/cmCTestConfigureHandler.h | 3 ++ Source/CTest/cmCTestCoverageHandler.cxx | 6 ++- Source/CTest/cmCTestCoverageHandler.h | 3 ++ Source/CTest/cmCTestGenericHandler.h | 9 +++- Source/CTest/cmCTestMemCheckHandler.cxx | 17 ++++++ Source/CTest/cmCTestMemCheckHandler.h | 3 ++ Source/CTest/cmCTestScriptHandler.cxx | 43 +++++++++++++++ Source/CTest/cmCTestScriptHandler.h | 2 + Source/CTest/cmCTestStartCommand.cxx | 1 + Source/CTest/cmCTestSubmitHandler.cxx | 11 ++++ Source/CTest/cmCTestSubmitHandler.h | 3 ++ Source/CTest/cmCTestTestHandler.cxx | 29 +++++++++++ Source/CTest/cmCTestTestHandler.h | 3 ++ Source/CTest/cmCTestUpdateCommand.cxx | 1 + Source/CTest/cmCTestUpdateHandler.cxx | 55 +++++++++++++++++-- Source/CTest/cmCTestUpdateHandler.h | 10 +++- Source/cmCTest.cxx | 6 +++ Source/cmCTest.h | 1 + Source/cmCommand.h | 49 ++--------------- Source/cmObject.h | 56 ++++++++++++++++++++ Source/cmStandardIncludes.h | 27 ++++++++++ 26 files changed, 361 insertions(+), 53 deletions(-) create mode 100644 Source/cmObject.h diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index aba5f4aee..01af29473 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -31,6 +31,11 @@ cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler() m_BuildNoCMake = false; } +//---------------------------------------------------------------------- +void cmCTestBuildAndTestHandler::Initialize() +{ +} + //---------------------------------------------------------------------- const char* cmCTestBuildAndTestHandler::GetOutput() { diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h index 788b28f86..3d1f30be8 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.h +++ b/Source/CTest/cmCTestBuildAndTestHandler.h @@ -31,6 +31,7 @@ class cmake; class cmCTestBuildAndTestHandler : public cmCTestGenericHandler { public: + cmTypeMacro(cmCTestBuildAndTestHandler, cmCTestGenericHandler); /* * The main entry point for this class @@ -49,6 +50,8 @@ public: cmCTestBuildAndTestHandler(); + virtual void Initialize(); + protected: ///! Run CMake and build a test and then run it as a single test. int RunCMakeAndTest(std::string* output); diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index ca9d54b9d..afae26b70 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -186,6 +186,64 @@ cmCTestBuildHandler::cmCTestBuildHandler() } } +//---------------------------------------------------------------------- +void cmCTestBuildHandler::Initialize() +{ + m_StartBuild = ""; + m_EndBuild = ""; + m_CustomErrorMatches.clear(); + m_CustomErrorExceptions.clear(); + m_CustomWarningMatches.clear(); + m_CustomWarningExceptions.clear(); + m_ErrorWarningFileLineRegex.clear(); + + m_ErrorMatchRegex.clear(); + m_ErrorExceptionRegex.clear(); + m_WarningMatchRegex.clear(); + m_WarningExceptionRegex.clear(); + m_BuildProcessingQueue.clear(); + m_BuildProcessingQueueLocation = m_BuildProcessingQueue.end(); + m_BuildOutputLogSize = 0; + m_CurrentProcessingLine.clear(); + + m_SimplifySourceDir = ""; + m_SimplifyBuildDir = ""; + m_OutputLineCounter = 0; + m_ErrorsAndWarnings.clear(); + m_LastErrorOrWarning = m_ErrorsAndWarnings.end(); + m_PostContextCount = 0; + m_MaxPreContext = 6; + m_MaxPostContext = 6; + m_PreContext.clear(); + + m_TotalErrors = 0; + m_TotalWarnings = 0; + m_LastTickChar = 0; + + m_ErrorQuotaReached = false; + m_WarningQuotaReached = false; + + m_MaxErrors = 50; + m_MaxWarnings = 50; + + int cc; + for ( cc = 0; cmCTestWarningErrorFileLine[cc].m_RegularExpressionString; ++ cc ) + { + cmCTestBuildHandler::cmCTestCompileErrorWarningRex r; + if ( r.m_RegularExpression.compile( + cmCTestWarningErrorFileLine[cc].m_RegularExpressionString) ) + { + r.m_FileIndex = cmCTestWarningErrorFileLine[cc].m_FileIndex; + r.m_LineIndex = cmCTestWarningErrorFileLine[cc].m_LineIndex; + m_ErrorWarningFileLineRegex.push_back(r); + } + else + { + cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem Compiling regular expression: " + << cmCTestWarningErrorFileLine[cc].m_RegularExpressionString << std::endl); + } + } +} //---------------------------------------------------------------------- void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf) diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h index b949e659f..9948300af 100644 --- a/Source/CTest/cmCTestBuildHandler.h +++ b/Source/CTest/cmCTestBuildHandler.h @@ -33,6 +33,7 @@ class cmMakefile; class cmCTestBuildHandler : public cmCTestGenericHandler { public: + cmTypeMacro(cmCTestBuildHandler, cmCTestGenericHandler); /* * The main entry point for this class @@ -43,6 +44,11 @@ public: void PopulateCustomVectors(cmMakefile *mf); + /** + * Initialize handler + */ + virtual void Initialize(); + private: //! Run command specialized for make and configure. Returns process status // and retVal is return value or exception. diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx index f5e8c97b5..b336f504c 100644 --- a/Source/CTest/cmCTestConfigureHandler.cxx +++ b/Source/CTest/cmCTestConfigureHandler.cxx @@ -28,6 +28,10 @@ cmCTestConfigureHandler::cmCTestConfigureHandler() { } +//---------------------------------------------------------------------- +void cmCTestConfigureHandler::Initialize() +{ +} //---------------------------------------------------------------------- //clearly it would be nice if this were broken up into a few smaller diff --git a/Source/CTest/cmCTestConfigureHandler.h b/Source/CTest/cmCTestConfigureHandler.h index e48f08857..07d7d7c60 100644 --- a/Source/CTest/cmCTestConfigureHandler.h +++ b/Source/CTest/cmCTestConfigureHandler.h @@ -29,6 +29,7 @@ class cmCTestConfigureHandler : public cmCTestGenericHandler { public: + cmTypeMacro(cmCTestConfigureHandler, cmCTestGenericHandler); /* * The main entry point for this class @@ -36,6 +37,8 @@ public: int ProcessHandler(); cmCTestConfigureHandler(); + + void Initialize(); }; #endif diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 31b1bb1b3..915eb8cf5 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -34,7 +34,11 @@ //---------------------------------------------------------------------- cmCTestCoverageHandler::cmCTestCoverageHandler() { - m_CTest = 0; +} + +//---------------------------------------------------------------------- +void cmCTestCoverageHandler::Initialize() +{ } //---------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index fc11df6d2..c2a686d98 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -31,6 +31,7 @@ class cmGeneratedFileStream; class cmCTestCoverageHandler : public cmCTestGenericHandler { public: + cmTypeMacro(cmCTestCoverageHandler, cmCTestGenericHandler); /* * The main entry point for this class @@ -39,6 +40,8 @@ public: cmCTestCoverageHandler(); + virtual void Initialize(); + private: bool ShouldIDoCoverage(const char* file, const char* srcDir, const char* binDir); diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index dccb70fe1..e2013a19b 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -19,7 +19,7 @@ #define cmCTestGenericHandler_h -#include "cmStandardIncludes.h" +#include "cmObject.h" class cmCTest; class cmMakefile; @@ -29,7 +29,7 @@ class cmCTestCommand; * \brief A superclass of all CTest Handlers * */ -class cmCTestGenericHandler +class cmCTestGenericHandler : public cmObject { public: /** @@ -55,6 +55,11 @@ public: const std::string& /*currentArg*/, size_t& /*idx*/, const std::vector& /*allArgs*/) { return 1; } + /** + * Initialize handler + */ + virtual void Initialize() = 0; + /** * Set the CTest instance */ diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index a5646c073..7665cba01 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -90,6 +90,23 @@ cmCTestMemCheckHandler::cmCTestMemCheckHandler() m_MemCheck = true; } +//---------------------------------------------------------------------- +void cmCTestMemCheckHandler::Initialize() +{ + this->Superclass::Initialize(); + m_MemoryTester = ""; + m_MemoryTesterOptionsParsed.clear(); + m_MemoryTesterOptions = ""; + m_MemoryTesterStyle = UNKNOWN; + m_MemoryTesterOutputFile = ""; + int cc; + for ( cc = 0; cc < NO_MEMORY_FAULT; cc ++ ) + { + m_MemoryTesterGlobalResults[cc] = 0; + } + +} + //---------------------------------------------------------------------- int cmCTestMemCheckHandler::PreProcessHandler() { diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index 8ff6a3c7d..483e2d6d9 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -31,10 +31,13 @@ class cmMakefile; class cmCTestMemCheckHandler : public cmCTestTestHandler { public: + cmTypeMacro(cmCTestMemCheckHandler, cmCTestTestHandler); + void PopulateCustomVectors(cmMakefile *mf); cmCTestMemCheckHandler(); + void Initialize(); protected: virtual int PreProcessHandler(); virtual int PostProcessHandler(); diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 2a408b100..f71983f17 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -97,6 +97,49 @@ cmCTestScriptHandler::cmCTestScriptHandler() m_ContinuousDuration = -1; } +//---------------------------------------------------------------------- +void cmCTestScriptHandler::Initialize() +{ + m_Backup = false; + m_EmptyBinDir = false; + m_EmptyBinDirOnce = false; + + m_SourceDir = ""; + m_BinaryDir = ""; + m_BackupSourceDir = ""; + m_BackupBinaryDir = ""; + m_CTestRoot = ""; + m_CVSCheckOut = ""; + m_CTestCmd = ""; + m_CVSCmd = ""; + m_CTestEnv = ""; + m_InitCache = ""; + m_CMakeCmd = ""; + m_CMOutFile = ""; + m_ExtraUpdates.clear(); + + m_MinimumInterval = 20*60; + m_ContinuousDuration = -1; + + // what time in seconds did this script start running + m_ScriptStartTime = 0; + + m_Makefile = 0; + if (m_LocalGenerator) + { + delete m_LocalGenerator; + } + m_LocalGenerator = 0; + if (m_GlobalGenerator) + { + delete m_GlobalGenerator; + } + m_GlobalGenerator = 0; + if (m_CMake) + { + delete m_CMake; + } +} //---------------------------------------------------------------------- cmCTestScriptHandler::~cmCTestScriptHandler() diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 3b7a882ef..94cb03a98 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -66,6 +66,7 @@ class cmCTestCommand; class cmCTestScriptHandler : public cmCTestGenericHandler { public: + cmTypeMacro(cmCTestScriptHandler, cmCTestGenericHandler); /** * Add a script to run @@ -97,6 +98,7 @@ public: cmCTestScriptHandler(); ~cmCTestScriptHandler(); + void Initialize(); private: // reads in a script int ReadInScript(const std::string& total_script_arg); diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index d3d364830..7b6645b0c 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -64,6 +64,7 @@ bool cmCTestStartCommand::InitialPass( this->SetError("binary directory not specified. Specify binary directory as an argument or set CTEST_BINARY_DIRECTORY"); return false; } + m_CTest->EmptyCTestConfiguration(); m_CTest->SetCTestConfiguration("SourceDirectory", src_dir); m_CTest->SetCTestConfiguration("BuildDirectory", bld_dir); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 930da220a..147166025 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -67,6 +67,17 @@ cmCTestSubmitHandler::cmCTestSubmitHandler() : m_HTTPProxy(), m_FTPProxy() m_FTPProxyType = 0; } +//---------------------------------------------------------------------------- +void cmCTestSubmitHandler::Initialize() +{ + m_HTTPProxy = ""; + m_HTTPProxyType = 0; + m_HTTPProxyAuth = ""; + m_FTPProxy = ""; + m_FTPProxyType = 0; + m_LogFile = 0; +} + //---------------------------------------------------------------------------- bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, const std::vector& files, diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 45d8f3018..804710fcc 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -28,6 +28,8 @@ class cmCTestSubmitHandler : public cmCTestGenericHandler { public: + cmTypeMacro(cmCTestSubmitHandler, cmCTestGenericHandler); + cmCTestSubmitHandler(); ~cmCTestSubmitHandler() { m_LogFile = 0; } @@ -36,6 +38,7 @@ public: */ int ProcessHandler(); + void Initialize(); private: void SetLogFile(std::ostream* ost) { m_LogFile = ost; } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index d84469dbc..7bd03450a 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -293,6 +293,35 @@ cmCTestTestHandler::cmCTestTestHandler() m_MemCheck = false; } +//---------------------------------------------------------------------- +void cmCTestTestHandler::Initialize() +{ + m_ElapsedTestingTime = -1; + + m_TestResults.clear(); + + m_CustomTestsIgnore.clear(); + m_StartTest = ""; + m_EndTest = ""; + + m_CustomPreTest.clear(); + m_CustomPostTest.clear(); + m_CustomMaximumPassedTestOutputSize = 1 * 1024; + m_CustomMaximumFailedTestOutputSize = 300 * 1024; + + m_TestsToRun.clear(); + + m_UseIncludeRegExp = false; + m_UseExcludeRegExp = false; + m_UseExcludeRegExpFirst = false; + m_IncludeRegExp = ""; + m_ExcludeRegExp = ""; + + TestsToRunString = ""; + m_UseUnion = false; + m_TestList.clear(); +} + //---------------------------------------------------------------------- void cmCTestTestHandler::PopulateCustomVectors(cmMakefile *mf) { diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 3076f4d16..0a716f768 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -31,6 +31,7 @@ class cmMakefile; class cmCTestTestHandler : public cmCTestGenericHandler { public: + cmTypeMacro(cmCTestTestHandler, cmCTestGenericHandler); /** * The main entry point for this class @@ -81,6 +82,8 @@ public: int m_TestCount; }; + void Initialize(); + protected: struct cmCTestTestProperties { diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx index 15b9e9043..50030d96f 100644 --- a/Source/CTest/cmCTestUpdateCommand.cxx +++ b/Source/CTest/cmCTestUpdateCommand.cxx @@ -66,6 +66,7 @@ bool cmCTestUpdateCommand::InitialPass( } } + m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "UpdateCommand", "CTEST_UPDATE_COMMAND"); m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "CVSCommand", "CTEST_CVS_COMMAND"); m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "SVNCommand", "CTEST_SVN_COMMAND"); diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx index 4758436c2..10856d307 100644 --- a/Source/CTest/cmCTestUpdateHandler.cxx +++ b/Source/CTest/cmCTestUpdateHandler.cxx @@ -38,6 +38,23 @@ #include #include +//---------------------------------------------------------------------- +static const char* cmCTestUpdateHandlerUpdateStrings[] = +{ + "Unknown", + "CVS", + "SVN" +}; + +static const char* cmCTestUpdateHandlerUpdateToString(int type) +{ + if ( type < cmCTestUpdateHandler::e_UNKNOWN || type >= cmCTestUpdateHandler::e_LAST ) + { + return cmCTestUpdateHandlerUpdateStrings[cmCTestUpdateHandler::e_UNKNOWN]; + } + return cmCTestUpdateHandlerUpdateStrings[type]; +} + //---------------------------------------------------------------------- //********************************************************************** class cmCTestUpdateHandlerSVNXMLParser : public cmXMLParser @@ -156,14 +173,20 @@ private: //---------------------------------------------------------------------- cmCTestUpdateHandler::cmCTestUpdateHandler() { - m_CTest = 0; +} + +//---------------------------------------------------------------------- +void cmCTestUpdateHandler::Initialize() +{ } //---------------------------------------------------------------------- int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type) { + cmCTestLog(m_CTest, DEBUG, "Determine update type from command: " << cmd << " and type: " << type << std::endl); if ( type && *type ) { + cmCTestLog(m_CTest, DEBUG, "Type specified: " << type << std::endl); std::string stype = cmSystemTools::LowerCase(type); if ( stype.find("cvs") != std::string::npos ) { @@ -176,6 +199,7 @@ int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type) } else { + cmCTestLog(m_CTest, DEBUG, "Type not specified, check command: " << cmd << std::endl); std::string stype = cmSystemTools::LowerCase(cmd); if ( stype.find("cvs") != std::string::npos ) { @@ -186,7 +210,20 @@ int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type) return cmCTestUpdateHandler::e_SVN; } } - return cmCTestUpdateHandler::e_CVS; + std::string sourceDirectory = this->GetOption("SourceDirectory"); + cmCTestLog(m_CTest, DEBUG, "Check directory: " << sourceDirectory.c_str() << std::endl); + sourceDirectory += "/.svn"; + if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) + { + return cmCTestUpdateHandler::e_SVN; + } + sourceDirectory = this->GetOption("SourceDirectory"); + sourceDirectory += "/CVS"; + if ( cmSystemTools::FileExists(sourceDirectory.c_str()) ) + { + return cmCTestUpdateHandler::e_CVS; + } + return cmCTestUpdateHandler::e_UNKNOWN; } //---------------------------------------------------------------------- @@ -285,6 +322,8 @@ int cmCTestUpdateHandler::ProcessHandler() updateType = this->DetermineType(updateCommand.c_str(), m_CTest->GetCTestConfiguration("UpdateType").c_str()); } + cmCTestLog(m_CTest, HANDLER_OUTPUT, " Use " << cmCTestUpdateHandlerUpdateToString(updateType) << " repository type" << std::endl;); + // And update options std::string updateOptions = m_CTest->GetCTestConfiguration("UpdateOptions"); if ( updateOptions.empty() ) @@ -434,6 +473,7 @@ int cmCTestUpdateHandler::ProcessHandler() &retVal, sourceDirectory, 0 /*m_TimeOut*/); ofs << " Output: " << partialOutput.c_str() << std::endl; ofs << " Errors: " << errors.c_str() << std::endl; + goutput = partialOutput; command = updateCommand + " status"; ofs << "* Status repository: " << std::endl; ofs << " Command: " << command.c_str() << std::endl; @@ -443,6 +483,7 @@ int cmCTestUpdateHandler::ProcessHandler() ofs << " Errors: " << errors.c_str() << std::endl; goutput += partialOutput; res = res && res1; + ofs << " Total output of update: " << goutput.c_str() << std::endl; } } if ( ofs ) @@ -467,7 +508,9 @@ int cmCTestUpdateHandler::ProcessHandler() << m_CTest->GetTestModelString() << "" << std::endl; os << "\t" << start_time << "\n" << "\t" << m_CTest->MakeXMLSafe(command) - << "\n"; + << "\n" + << "\t" << m_CTest->MakeXMLSafe(cmCTestUpdateHandlerUpdateToString(updateType)) + << "\n"; // Even though it failed, we may have some useful information. Try to continue... std::vector lines; @@ -503,7 +546,11 @@ int cmCTestUpdateHandler::ProcessHandler() } } } - if ( updateType == cmCTestUpdateHandler::e_SVN ) + if ( svn_latest_revision <= 0 ) + { + cmCTestLog(m_CTest, ERROR_MESSAGE, "Problem determining the current revision of the repository from output:" << std::endl << goutput.c_str() << std::endl); + } + else if ( updateType == cmCTestUpdateHandler::e_SVN ) { cmCTestLog(m_CTest, HANDLER_OUTPUT, " Current revision of repository is: " << svn_latest_revision << std::endl); } diff --git a/Source/CTest/cmCTestUpdateHandler.h b/Source/CTest/cmCTestUpdateHandler.h index 019ee571b..bcef45e5c 100644 --- a/Source/CTest/cmCTestUpdateHandler.h +++ b/Source/CTest/cmCTestUpdateHandler.h @@ -33,6 +33,7 @@ class cmCTestUpdateHandler : public cmCTestGenericHandler { public: + cmTypeMacro(cmCTestUpdateHandler, cmCTestGenericHandler); /* * The main entry point for this class @@ -42,9 +43,16 @@ public: cmCTestUpdateHandler(); enum { + e_UNKNOWN = 0, e_CVS, - e_SVN + e_SVN, + e_LAST }; + + /** + * Initialize handler + */ + virtual void Initialize(); private: // Some structures needed for update diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index b782cd358..f3ff28969 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1799,6 +1799,12 @@ std::string cmCTest::GetCTestConfiguration(const char *name) return m_CTestConfiguration[name]; } +//---------------------------------------------------------------------- +void cmCTest::EmptyCTestConfiguration() +{ + m_CTestConfiguration.clear(); +} + //---------------------------------------------------------------------- void cmCTest::SetCTestConfiguration(const char *name, const char* value) { diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 4d77a9562..bd7d74b32 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -114,6 +114,7 @@ public: static std::string CleanString(const std::string& str); std::string GetCTestConfiguration(const char *name); void SetCTestConfiguration(const char *name, const char* value); + void EmptyCTestConfiguration(); /** * constructor and destructor diff --git a/Source/cmCommand.h b/Source/cmCommand.h index d26eea5d8..014304734 100644 --- a/Source/cmCommand.h +++ b/Source/cmCommand.h @@ -17,6 +17,7 @@ #ifndef cmCommand_h #define cmCommand_h +#include "cmObject.h" #include "cmListFileCache.h" #include "cmMakefile.h" @@ -30,9 +31,11 @@ * to support such features as enable/disable, inheritance, * documentation, and construction. */ -class cmCommand +class cmCommand : public cmObject { public: + cmTypeMacro(cmCommand, cmObject); + /** * Construct the command. By default it is enabled with no makefile. */ @@ -103,11 +106,6 @@ public: */ virtual const char* GetName() = 0; - /** - * The class name of the command. - */ - virtual const char* GetNameOfClass() = 0; - /** * Succinct documentation. */ @@ -155,19 +153,6 @@ public: return m_Error.c_str(); } - /** - * Returns true if this class is the given class, or a subclass of it. - */ - static bool IsTypeOf(const char *type) - { return !strcmp("cmCommand", type); } - - /** - * Returns true if this object is an instance of the given class or - * a subclass of it. - */ - virtual bool IsA(const char *type) - { return cmCommand::IsTypeOf(type); } - /** * Set the error message */ @@ -186,30 +171,4 @@ private: std::string m_Error; }; -// All subclasses of cmCommand should invoke this macro. -#define cmTypeMacro(thisClass,superclass) \ -virtual const char* GetNameOfClass() { return #thisClass; } \ -typedef superclass Superclass; \ -static bool IsTypeOf(const char *type) \ -{ \ - if ( !strcmp(#thisClass,type) ) \ - { \ - return true; \ - } \ - return Superclass::IsTypeOf(type); \ -} \ -virtual bool IsA(const char *type) \ -{ \ - return thisClass::IsTypeOf(type); \ -} \ -static thisClass* SafeDownCast(cmCommand *c) \ -{ \ - if ( c && c->IsA(#thisClass) ) \ - { \ - return (thisClass *)c; \ - } \ - return 0;\ -} - - #endif diff --git a/Source/cmObject.h b/Source/cmObject.h new file mode 100644 index 000000000..99ab31d58 --- /dev/null +++ b/Source/cmObject.h @@ -0,0 +1,56 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef cmObject_h +#define cmObject_h + +#include "cmStandardIncludes.h" + +/** \class cmObject + * \brief Superclass for all commands and other classes in CMake. + * + * cmObject is the base class for all classes in CMake. It defines some methods + * such as GetNameOfClass, IsA, SafeDownCast. + */ +class cmObject +{ +public: + /** + * Need virtual destructor to destroy real command type. + */ + virtual ~cmObject() {} + + /** + * The class name of the command. + */ + virtual const char* GetNameOfClass() = 0; + + /** + * Returns true if this class is the given class, or a subclass of it. + */ + static bool IsTypeOf(const char *type) + { return !strcmp("cmObject", type); } + + /** + * Returns true if this object is an instance of the given class or + * a subclass of it. + */ + virtual bool IsA(const char *type) + { return cmObject::IsTypeOf(type); } +}; + +#endif + diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index ae8333219..70d2048bf 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -323,4 +323,31 @@ public: # pragma reset woff 1375 /* base class destructor not virtual */ #endif +// All subclasses of cmCommand or cmCTestGenericHandler should invoke this macro. +#define cmTypeMacro(thisClass,superclass) \ +virtual const char* GetNameOfClass() { return #thisClass; } \ +typedef superclass Superclass; \ +static bool IsTypeOf(const char *type) \ +{ \ + if ( !strcmp(#thisClass,type) ) \ + { \ + return true; \ + } \ + return Superclass::IsTypeOf(type); \ +} \ +virtual bool IsA(const char *type) \ +{ \ + return thisClass::IsTypeOf(type); \ +} \ +static thisClass* SafeDownCast(cmObject *c) \ +{ \ + if ( c && c->IsA(#thisClass) ) \ + { \ + return (thisClass *)c; \ + } \ + return 0;\ +} + + + #endif