diff options
author | Ken Martin <ken.martin@kitware.com> | 2003-12-02 00:25:51 (GMT) |
---|---|---|
committer | Ken Martin <ken.martin@kitware.com> | 2003-12-02 00:25:51 (GMT) |
commit | a442f1715ee6c3800973fb2b8b21f353fc89a42f (patch) | |
tree | 7aa166bb46ac6bf0b5d942d317af4a1e62c216a0 /Source | |
parent | 81be61b15358a337ff00ccf57558b77d54004022 (diff) | |
download | CMake-a442f1715ee6c3800973fb2b8b21f353fc89a42f.zip CMake-a442f1715ee6c3800973fb2b8b21f353fc89a42f.tar.gz CMake-a442f1715ee6c3800973fb2b8b21f353fc89a42f.tar.bz2 |
a start on the dashboard driver
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCTest.cxx | 172 | ||||
-rw-r--r-- | Source/cmCTest.h | 8 | ||||
-rw-r--r-- | Source/ctest.cxx | 28 |
3 files changed, 195 insertions, 13 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 4689a18..9b4dcc0 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -15,7 +15,11 @@ =========================================================================*/ #include "cmCTest.h" -#include "cmSystemTools.h" +#include "cmake.h" +#include "cmMakefile.h" +#include "cmLocalGenerator.h" +#include "cmGlobalGenerator.h" +#include <cmsys/Directory.hxx> #include "cmListFileCache.h" #ifdef HAVE_CURL @@ -258,14 +262,15 @@ bool TryExecutable(const char *dir, const char *file, cmCTest::cmCTest() { - m_UseIncludeRegExp = false; - m_UseExcludeRegExp = false; - m_UseExcludeRegExpFirst = false; - m_Verbose = false; - m_DartMode = false; - m_ShowOnly = false; - m_TestModel = cmCTest::EXPERIMENTAL; - m_TimeOut = 0; + m_UseIncludeRegExp = false; + m_UseExcludeRegExp = false; + m_UseExcludeRegExpFirst = false; + m_Verbose = false; + m_DartMode = false; + m_ShowOnly = false; + m_RunConfigurationScript = false; + m_TestModel = cmCTest::EXPERIMENTAL; + m_TimeOut = 0; int cc; for ( cc=0; cc < cmCTest::LAST_TEST; cc ++ ) { @@ -2518,3 +2523,152 @@ const char* cmCTest::GetTestStatus(int status) } return statuses[status]; } + + +void cmCTestRemoveDirectory(const char *binDir) +{ + cmsys::Directory dir; + dir.Load(binDir); + size_t fileNum; + for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) + { + if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".") && + strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),"..")) + { + std::string fullPath = binDir; + fullPath += "/"; + fullPath += dir.GetFile(static_cast<unsigned long>(fileNum)); + if(cmSystemTools::FileIsDirectory(fullPath.c_str())) + { + cmCTestRemoveDirectory(fullPath.c_str()); + } + else + { + if(!cmSystemTools::RemoveFile(fullPath.c_str())) + { + std::string m = "Remove failed on file: "; + m += fullPath; + cmSystemTools::ReportLastSystemError(m.c_str()); + } + } + } + } +} + +int cmCTest::RunConfigurationScript() +{ + m_ConfigurationScript = + cmSystemTools::CollapseFullPath(m_ConfigurationScript.c_str()); + + // make sure the file exists + if (!cmSystemTools::FileExists(m_ConfigurationScript.c_str())) + { + return -1; + } + + // create a cmake instance to read the configuration script + cmake cm; + cmGlobalGenerator gg; + gg.SetCMakeInstance(&cm); + + // read in the list file to fill the cache + cmLocalGenerator *lg = gg.CreateLocalGenerator(); + lg->SetGlobalGenerator(&gg); + if (!lg->GetMakefile()->ReadListFile(0, m_ConfigurationScript.c_str())) + { + return -2; + } + + // no popup widows + cmSystemTools::SetRunCommandHideConsole(true); + + // get some info that should be set + cmMakefile *mf = lg->GetMakefile(); + const char *srcDir = mf->GetDefinition("CTEST_SOURCE_DIRECTORY"); + const char *binDir = mf->GetDefinition("CTEST_BINARY_DIRECTORY"); + const char *ctestCmd = mf->GetDefinition("CTEST_COMMAND"); + + // make sure the required info is here + if (!srcDir || !binDir || !ctestCmd) + { + cmSystemTools::Error("Some required settings in the configuration file were missing"); + return -3; + } + + // clear the binary directory? + if (mf->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY")) + { + // try to avoid deleting directories that we shouldn't + std::string check = binDir; + check += "/CMakeCache.txt"; + if (cmSystemTools::FileExists(check.c_str())) + { + cmCTestRemoveDirectory(binDir); + } + } + + // make sure the binary directory exists + if (!cmSystemTools::FileExists(binDir)) + { + if (!cmSystemTools::MakeDirectory(binDir)) + { + cmSystemTools::Error("Unable to create the binary directory"); + return -4; + } + } + + std::string command; + std::string output; + int retVal = 0; + bool res = 0; + + // do an initial cvs update on the src dir + const char *cvsCmd = mf->GetDefinition("CTEST_CVS_COMMAND"); + if (cvsCmd) + { + command = cvsCmd; + output.empty(); + retVal = 0; + res = cmSystemTools::RunSingleCommand(command.c_str(), &output, + &retVal, binDir, + m_Verbose, 0 /*m_TimeOut*/); + } + + // put the initial cache into the bin dir + if (mf->GetDefinition("CTEST_INITIAL_CACHE")) + { + // the cache file will always be next to the configuration script + std::string initialCache = + cmSystemTools::GetFilenamePath(m_ConfigurationScript); + initialCache += "/"; + initialCache += mf->GetDefinition("CTEST_INITIAL_CACHE"); + std::string destCache = binDir; + destCache += "/CMakeCache.txt"; + cmSystemTools::CopyFileIfDifferent(initialCache.c_str(), + destCache.c_str()); + } + + // do an initial cmake to setup the DartConfig file + const char *cmakeCmd = mf->GetDefinition("CTEST_CMAKE_COMMAND"); + if (cmakeCmd) + { + command = cmakeCmd; + command += " "; + command += srcDir; + output.empty(); + retVal = 0; + res = cmSystemTools::RunSingleCommand(command.c_str(), &output, + &retVal, binDir, + m_Verbose, 0 /*m_TimeOut*/); + } + + // run ctest + command = ctestCmd; + output.empty(); + retVal = 0; + res = cmSystemTools::RunSingleCommand(command.c_str(), &output, + &retVal, binDir, + m_Verbose, 0 /*m_TimeOut*/); + + return 0; +} diff --git a/Source/cmCTest.h b/Source/cmCTest.h index ee19740..9be9346 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -25,6 +25,11 @@ class cmCTest { public: /** + * Run a dashboard using a specified confiuration script + */ + int RunConfigurationScript(); + + /** * Initialize and finalize testing */ void Initialize(); @@ -120,6 +125,9 @@ public: bool m_DartMode; bool m_ShowOnly; + bool m_RunConfigurationScript; + std::string m_ConfigurationScript; + enum { EXPERIMENTAL, NIGHTLY, diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 090b535..ef7a5c7 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -73,6 +73,12 @@ static const cmDocumentationEntry cmDocumentationOptions[] = "a dashboard test. All tests are ModeTest, where Mode can be Experimental, " "Nightly, and Continuous, and Test can be Start, Update, Configure, " "Build, Test, Coverage, and Submit."}, + {"-S <ConfigScript>", "Execute a dashboard for a configuration", + "This option tells ctest to load in a configuration script which sets " + "a number of parameters such as the binary and source directories. Then " + "ctest will do what is required to create and run a dashboard. This " + "option basically sets up a dashboard and then runs ctest -D with the " + "appropriate options."}, {0,0,0} }; @@ -146,6 +152,12 @@ int main (int argc, char *argv[]) inst.m_ShowOnly = true; } + if( arg.find("-S",0) == 0 && i < args.size() - 1 ) + { + inst.m_RunConfigurationScript = true; + inst.m_ConfigurationScript = args[i+1]; + } + if( arg.find("-D",0) == 0 && i < args.size() - 1 ) { inst.m_DartMode = true; @@ -367,10 +379,18 @@ int main (int argc, char *argv[]) } // call process directory - inst.Initialize(); - int res = inst.ProcessTests(); - inst.Finalize(); - + int res; + if (inst.m_RunConfigurationScript) + { + res = inst.RunConfigurationScript(); + } + else + { + inst.Initialize(); + res = inst.ProcessTests(); + inst.Finalize(); + } + return res; } |