Commit dc0ce24c authored by Andy Cedilnik's avatar Andy Cedilnik
Browse files

ENH: Add a superclass to all handlers

parent bf3d7746
......@@ -139,6 +139,7 @@ ADD_EXECUTABLE(cmake cmakemain.cxx)
ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation)
SET(CMTEST_SRCS ctest.cxx cmCTest.cxx
CTest/cmCTestGenericHandler.cxx
CTest/cmCTestBuildHandler.cxx
CTest/cmCTestConfigureHandler.cxx
CTest/cmCTestCoverageHandler.cxx
......
......@@ -156,8 +156,6 @@ cmCTestWarningErrorFileLine[] = {
//----------------------------------------------------------------------
cmCTestBuildHandler::cmCTestBuildHandler()
{
m_Verbose = false;
m_CTest = 0;
int cc;
for ( cc = 0; cmCTestWarningErrorFileLine[cc].m_RegularExpressionString; ++ cc )
{
......@@ -194,10 +192,8 @@ void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf)
//----------------------------------------------------------------------
//clearly it would be nice if this were broken up into a few smaller
//functions and commented...
int cmCTestBuildHandler::BuildDirectory(cmCTest *ctest_inst)
int cmCTestBuildHandler::BuildDirectory()
{
m_CTest = ctest_inst;
std::cout << "Build project" << std::endl;
std::string makeCommand = m_CTest->GetDartConfiguration("MakeCommand");
if ( makeCommand.size() == 0 )
......
......@@ -19,31 +19,25 @@
#define cmCTestBuildHandler_h
#include "cmStandardIncludes.h"
#include "cmCTestGenericHandler.h"
#include "cmListFileCache.h"
#include <cmsys/RegularExpression.hxx>
class cmCTest;
class cmMakefile;
/** \class cmCTestBuildHandler
* \brief A class that handles ctest -S invocations
*
*/
class cmCTestBuildHandler
class cmCTestBuildHandler : public cmCTestGenericHandler
{
public:
/*
* The main entry point for this class
*/
int BuildDirectory(cmCTest *);
/*
* If verbose then more informaiton is printed out
*/
void SetVerbose(bool val) { m_Verbose = val; }
int BuildDirectory();
cmCTestBuildHandler();
......@@ -77,9 +71,6 @@ private:
double elapsed_time);
bool m_Verbose;
cmCTest *m_CTest;
std::string m_StartBuild;
std::string m_EndBuild;
......
......@@ -34,10 +34,8 @@ cmCTestConfigureHandler::cmCTestConfigureHandler()
//----------------------------------------------------------------------
//clearly it would be nice if this were broken up into a few smaller
//functions and commented...
int cmCTestConfigureHandler::ConfigureDirectory(cmCTest *ctest_inst)
int cmCTestConfigureHandler::ConfigureDirectory()
{
m_CTest = ctest_inst;
std::cout << "Configure project" << std::endl;
std::string cCommand = m_CTest->GetDartConfiguration("ConfigureCommand");
if ( cCommand.size() == 0 )
......
......@@ -19,35 +19,23 @@
#define cmCTestConfigureHandler_h
#include "cmStandardIncludes.h"
#include "cmCTestGenericHandler.h"
#include "cmListFileCache.h"
class cmCTest;
/** \class cmCTestConfigureHandler
* \brief A class that handles ctest -S invocations
*
*/
class cmCTestConfigureHandler
class cmCTestConfigureHandler : public cmCTestGenericHandler
{
public:
/*
* The main entry point for this class
*/
int ConfigureDirectory(cmCTest *);
/*
* If verbose then more informaiton is printed out
*/
void SetVerbose(bool val) { m_Verbose = val; }
int ConfigureDirectory();
cmCTestConfigureHandler();
private:
bool m_Verbose;
cmCTest *m_CTest;
};
#endif
......@@ -154,10 +154,8 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file, const char* src
//----------------------------------------------------------------------
//clearly it would be nice if this were broken up into a few smaller
//functions and commented...
int cmCTestCoverageHandler::CoverageDirectory(cmCTest *ctest_inst)
int cmCTestCoverageHandler::CoverageDirectory()
{
m_CTest = ctest_inst;
int error = 0;
std::string sourceDir = m_CTest->GetDartConfiguration("SourceDirectory");
......
......@@ -19,35 +19,27 @@
#define cmCTestCoverageHandler_h
#include "cmStandardIncludes.h"
#include "cmCTestGenericHandler.h"
#include "cmListFileCache.h"
class cmCTest;
class cmGeneratedFileStream;
/** \class cmCTestCoverageHandler
* \brief A class that handles coverage computaiton for ctest
*
*/
class cmCTestCoverageHandler
class cmCTestCoverageHandler : public cmCTestGenericHandler
{
public:
/*
* The main entry point for this class
*/
int CoverageDirectory(cmCTest *);
/*
* If verbose then more informaiton is printed out
*/
void SetVerbose(bool val) { m_Verbose = val; }
int CoverageDirectory();
cmCTestCoverageHandler();
private:
bool m_Verbose;
cmCTest *m_CTest;
bool ShouldIDoCoverage(const char* file, const char* srcDir,
const char* binDir, bool verbose);
bool StartLogFile(cmGeneratedFileStream& ostr, int logFileCount);
......
/*=========================================================================
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.
=========================================================================*/
#include "cmCTestGenericHandler.h"
cmCTestGenericHandler::cmCTestGenericHandler()
{
m_Verbose = false;
m_CTest = 0;
}
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc. 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 cmCTestGenericHandler_h
#define cmCTestGenericHandler_h
#include "cmStandardIncludes.h"
class cmCTest;
class cmMakefile;
/** \class cmCTestGenericHandler
* \brief A superclass of all CTest Handlers
*
*/
class cmCTestGenericHandler
{
public:
/**
* If verbose then more informaiton is printed out
*/
void SetVerbose(bool val) { m_Verbose = val; }
/**
* Populate internals from CTest custom scripts
*/
void PopulateCustomVectors(cmMakefile *) {}
/**
* Set the CTest instance
*/
void SetCTestInstance(cmCTest* ctest) { m_CTest = ctest; }
/**
* Construct handler
*/
cmCTestGenericHandler();
protected:
bool m_Verbose;
cmCTest *m_CTest;
};
#endif
......@@ -125,7 +125,7 @@ void cmCTestScriptHandler::AddConfigurationScript(const char *script)
//----------------------------------------------------------------------
// the generic entry point for handling scripts, this routine will run all
// the scripts provides a -S arguments
int cmCTestScriptHandler::RunConfigurationScript(cmCTest* ctest)
int cmCTestScriptHandler::RunConfigurationScript()
{
int res = 0;
std::vector<cmStdString>::iterator it;
......@@ -134,7 +134,7 @@ int cmCTestScriptHandler::RunConfigurationScript(cmCTest* ctest)
it ++ )
{
// for each script run it
res += this->RunConfigurationScript(ctest,
res += this->RunConfigurationScript(
cmSystemTools::CollapseFullPath(it->c_str()));
}
return res;
......@@ -157,8 +157,7 @@ void cmCTestScriptHandler::UpdateElapsedTime()
//----------------------------------------------------------------------
// this sets up some variables for thew script to use, creates the required
// cmake instance and generators, and then reads in the script
int cmCTestScriptHandler::ReadInScript(cmCTest* ctest,
const std::string& total_script_arg)
int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
{
// if the argument has a , in it then it needs to be broken into the fist
// argument (which is the script) and the second argument which will be
......@@ -201,7 +200,7 @@ int cmCTestScriptHandler::ReadInScript(cmCTest* ctest,
cmSystemTools::GetFilenameName(
script).c_str());
m_LocalGenerator->GetMakefile()->AddDefinition("CTEST_EXECUTABLE_NAME",
ctest->GetCTestExecutable());
m_CTest->GetCTestExecutable());
this->UpdateElapsedTime();
......@@ -209,15 +208,15 @@ int cmCTestScriptHandler::ReadInScript(cmCTest* ctest,
// for ctest commands to clean this up. If a couple more commands are
// created with the same format lets do that - ken
cmCTestCommand* newCom = new cmCTestRunScriptCommand;
newCom->m_CTest = ctest;
newCom->m_CTest = m_CTest;
newCom->m_CTestScriptHandler = this;
m_CMake->AddCommand(newCom);
newCom = new cmCTestEmptyBinaryDirectoryCommand;
newCom->m_CTest = ctest;
newCom->m_CTest = m_CTest;
newCom->m_CTestScriptHandler = this;
m_CMake->AddCommand(newCom);
newCom = new cmCTestSleepCommand;
newCom->m_CTest = ctest;
newCom->m_CTest = m_CTest;
newCom->m_CTestScriptHandler = this;
m_CMake->AddCommand(newCom);
......@@ -349,8 +348,7 @@ void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait)
//----------------------------------------------------------------------
// run a specific script
int cmCTestScriptHandler::RunConfigurationScript(cmCTest* ctest,
const std::string& total_script_arg)
int cmCTestScriptHandler::RunConfigurationScript(const std::string& total_script_arg)
{
int result;
......@@ -358,7 +356,7 @@ int cmCTestScriptHandler::RunConfigurationScript(cmCTest* ctest,
cmSystemTools::GetTime();
// read in the script
result = this->ReadInScript(ctest, total_script_arg);
result = this->ReadInScript(total_script_arg);
if (result)
{
return result;
......@@ -761,11 +759,12 @@ void cmCTestScriptHandler::RestoreBackupDirectories()
}
}
bool cmCTestScriptHandler::RunScript(cmCTest *ctest, const char *sname)
bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char *sname)
{
cmCTestScriptHandler* sh = new cmCTestScriptHandler();
sh->SetCTestInstance(ctest);
sh->AddConfigurationScript(sname);
sh->RunConfigurationScript(ctest);
sh->RunConfigurationScript();
delete sh;
return true;
}
......
......@@ -19,14 +19,13 @@
#define cmCTestScriptHandler_h
#include "cmStandardIncludes.h"
#include "cmCTestGenericHandler.h"
#include "cmListFileCache.h"
class cmMakefile;
class cmLocalGenerator;
class cmGlobalGenerator;
class cmake;
class cmCTest;
/** \class cmCTestScriptHandler
* \brief A class that handles ctest -S invocations
......@@ -63,7 +62,7 @@ class cmCTest;
* CTEST_SCRIPT_NAME
*
*/
class cmCTestScriptHandler
class cmCTestScriptHandler : public cmCTestGenericHandler
{
public:
......@@ -75,12 +74,7 @@ public:
/**
* Run a dashboard using a specified confiuration script
*/
int RunConfigurationScript(cmCTest* ctest);
/*
* If verbose then more informaiton is printed out
*/
void SetVerbose(bool val) { m_Verbose = val; }
int RunConfigurationScript();
/*
* Run a script
......@@ -104,7 +98,7 @@ public:
private:
// reads in a script
int ReadInScript(cmCTest* ctest, const std::string& total_script_arg);
int ReadInScript(const std::string& total_script_arg);
// extract vars from the script to set ivars
int ExtractVariables();
......@@ -119,12 +113,11 @@ private:
int BackupDirectories();
void RestoreBackupDirectories();
int RunConfigurationScript(cmCTest* ctest, const std::string& script);
int RunConfigurationScript(const std::string& script);
int RunConfigurationDashboard();
std::vector<cmStdString> m_ConfigurationScripts;
bool m_Verbose;
bool m_Backup;
bool m_EmptyBinDir;
bool m_EmptyBinDirOnce;
......
......@@ -192,8 +192,6 @@ inline int GetNextRealNumber(std::string const& in,
//----------------------------------------------------------------------
cmCTestTestHandler::cmCTestTestHandler()
{
m_Verbose = false;
m_CTest = 0;
m_UseUnion = false;
m_UseIncludeRegExp = false;
......@@ -234,10 +232,8 @@ void cmCTestTestHandler::PopulateCustomVectors(cmMakefile *mf)
//----------------------------------------------------------------------
//clearly it would be nice if this were broken up into a few smaller
//functions and commented...
int cmCTestTestHandler::TestDirectory(cmCTest *ctest_inst, bool memcheck)
int cmCTestTestHandler::TestDirectory(bool memcheck)
{
m_CTest = ctest_inst;
m_TestResults.clear();
std::cout << (memcheck ? "Memory check" : "Test") << " project" << std::endl;
if ( memcheck )
......
......@@ -19,30 +19,24 @@
#define cmCTestTestHandler_h
#include "cmStandardIncludes.h"
#include "cmCTestGenericHandler.h"
#include "cmListFileCache.h"
class cmCTest;
class cmMakefile;
/** \class cmCTestTestHandler
* \brief A class that handles ctest -S invocations
*
*/
class cmCTestTestHandler
class cmCTestTestHandler : public cmCTestGenericHandler
{
public:
/*
* The main entry point for this class
*/
int TestDirectory(cmCTest *, bool memcheck);
int TestDirectory(bool memcheck);
/*
* If verbose then more informaiton is printed out
*/
void SetVerbose(bool val) { m_Verbose = val; }
/*
* When both -R and -I are used should te resulting test list be the
* intersection or the union of the lists. By default it is the
......@@ -114,9 +108,6 @@ private:
COMPLETED
};
bool m_Verbose;
cmCTest *m_CTest;
std::string m_MemoryTester;
std::vector<cmStdString> m_MemoryTesterOptionsParsed;
std::string m_MemoryTesterOptions;
......
......@@ -49,10 +49,8 @@ cmCTestUpdateHandler::cmCTestUpdateHandler()
//----------------------------------------------------------------------
//clearly it would be nice if this were broken up into a few smaller
//functions and commented...
int cmCTestUpdateHandler::UpdateDirectory(cmCTest *ctest_inst)
int cmCTestUpdateHandler::UpdateDirectory()
{
m_CTest = ctest_inst;
int count = 0;
std::string::size_type cc, kk;
std::string cvsCommand = m_CTest->GetDartConfiguration("CVSCommand");
......
......@@ -19,35 +19,25 @@
#define cmCTestUpdateHandler_h
#include "cmStandardIncludes.h"
#include "cmCTestGenericHandler.h"
#include "cmListFileCache.h"
class cmCTest;
/** \class cmCTestUpdateHandler
* \brief A class that handles ctest -S invocations
*
*/
class cmCTestUpdateHandler
class cmCTestUpdateHandler : public cmCTestGenericHandler
{
public:
/*
* The main entry point for this class
*/
int UpdateDirectory(cmCTest *);
/*
* If verbose then more informaiton is printed out
*/
void SetVerbose(bool val) { m_Verbose = val; }
int UpdateDirectory();
cmCTestUpdateHandler();
private:
bool m_Verbose;
cmCTest *m_CTest;
// Some structures needed for cvs update
struct StringPair :
public std::pair<std::string, std::string>{};
......
......@@ -246,6 +246,13 @@ cmCTest::cmCTest()
this->TestHandler = new cmCTestTestHandler;
this->UpdateHandler = new cmCTestUpdateHandler;
this->ConfigureHandler = new cmCTestConfigureHandler;
this->BuildHandler->SetCTestInstance(this);
this->CoverageHandler->SetCTestInstance(this);
this->ScriptHandler->SetCTestInstance(this);
this->TestHandler->SetCTestInstance(this);
this->UpdateHandler->SetCTestInstance(this);
this->ConfigureHandler->SetCTestInstance(this);
}
cmCTest::~cmCTest()
......@@ -720,7 +727,7 @@ int cmCTest::ProcessTests()
}
if ( m_Tests[UPDATE_TEST] || m_Tests[ALL_TEST] )
{
update_count = this->UpdateHandler->UpdateDirectory(this);
update_count = this->UpdateHandler->UpdateDirectory();
if ( update_count < 0 )
{
res |= cmCTest::UPDATE_ERRORS;
......@@ -732,7 +739,7 @@ int cmCTest::ProcessTests()
}
if ( m_Tests[CONFIGURE_TEST] || m_Tests[ALL_TEST] )
{
if (this->ConfigureHandler->ConfigureDirectory(this))
if (this->ConfigureHandler->ConfigureDirectory())
{
res |= cmCTest::CONFIGURE_ERRORS;
}
......@@ -740,7 +747,7 @@ int cmCTest::ProcessTests()
if ( m_Tests[BUILD_TEST] || m_Tests[ALL_TEST] )
{
this->UpdateCTestConfiguration();
if (this->BuildHandler->BuildDirectory(this))
if (this->BuildHandler->BuildDirectory())
{
res |= cmCTest::BUILD_ERRORS;
}
......@@ -748,7 +755,7 @@ int cmCTest::ProcessTests()
if ( m_Tests[TEST_TEST] || m_Tests[ALL_TEST] || notest )
{
this->UpdateCTestConfiguration();
if (this->TestHandler->TestDirectory(this,false))
if (this->TestHandler->TestDirectory(false))
{
res |= cmCTest::TEST_ERRORS;
}
......@@ -756,7 +763,7 @@ int cmCTest::ProcessTests()
if ( m_Tests[COVERAGE_TEST] || m_Tests[ALL_TEST] )
{
this->UpdateCTestConfiguration();
if (this->CoverageHandler->CoverageDirectory(this))
if (this->CoverageHandler->CoverageDirectory())
{
res |= cmCTest::COVERAGE_ERRORS;
}
......@@ -764,7 +771,7 @@ int cmCTest::ProcessTests()
if ( m_Tests[MEMCHECK_TEST] || m_Tests[ALL_TEST] )
{
this->UpdateCTestConfiguration();
if (this->TestHandler->TestDirectory(this,true))
if (this->TestHandler->TestDirectory(true))
{
res |= cmCTest::MEMORY_ERRORS;
}
......@@ -1600,7 +1607,7 @@ int cmCTest::Run(std::vector<std::string>const& args, std::string* output)
// call process directory
if (this->m_RunConfigurationScript)
{
res = this->ScriptHandler->RunConfigurationScript(this);
res = this->ScriptHandler->RunConfigurationScript();
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment