summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2009-07-11 20:30:18 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2009-07-11 20:30:18 (GMT)
commit46f99c656531d52d9377ee2c82455b556592428f (patch)
tree860d611364ae7e4beb74ee37d71cb58695e4e43d /Source/CTest
parenta605bd5225ce062670f50b3a6a8e0b84be002bb1 (diff)
downloadCMake-46f99c656531d52d9377ee2c82455b556592428f.zip
CMake-46f99c656531d52d9377ee2c82455b556592428f.tar.gz
CMake-46f99c656531d52d9377ee2c82455b556592428f.tar.bz2
STYLE: move the code for writing the initial cache into its own separate
function, makes the long ProcessHandler() a little bit shorter Alex
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx38
-rw-r--r--Source/CTest/cmCTestScriptHandler.h5
2 files changed, 31 insertions, 12 deletions
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 6476d54..89c98c6 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -881,22 +881,12 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
// put the initial cache into the bin dir
if (!this->InitialCache.empty())
{
- std::string cacheFile = this->BinaryDir;
- cacheFile += "/CMakeCache.txt";
- cmGeneratedFileStream fout(cacheFile.c_str());
- if(!fout)
+ if (!this->WriteInitialCache(this->BinaryDir.c_str(),
+ this->InitialCache.c_str()))
{
this->RestoreBackupDirectories();
return 9;
}
-
- fout.write(this->InitialCache.c_str(), this->InitialCache.size());
-
- // Make sure the operating system has finished writing the file
- // before closing it. This will ensure the file is finished before
- // the check below.
- fout.flush();
- fout.close();
}
// do an initial cmake to setup the DartConfig file
@@ -995,6 +985,30 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
return 0;
}
+//-------------------------------------------------------------------------
+bool cmCTestScriptHandler::WriteInitialCache(const char* directory,
+ const char* text)
+{
+ std::string cacheFile = directory;
+ cacheFile += "/CMakeCache.txt";
+ cmGeneratedFileStream fout(cacheFile.c_str());
+ if(!fout)
+ {
+ return false;
+ }
+
+ if (text!=0)
+ {
+ fout.write(text, strlen(text));
+ }
+
+ // Make sure the operating system has finished writing the file
+ // before closing it. This will ensure the file is finished before
+ // the check below.
+ fout.flush();
+ fout.close();
+ return true;
+}
//-------------------------------------------------------------------------
void cmCTestScriptHandler::RestoreBackupDirectories()
diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h
index c44cff0..709b928 100644
--- a/Source/CTest/cmCTestScriptHandler.h
+++ b/Source/CTest/cmCTestScriptHandler.h
@@ -91,6 +91,11 @@ public:
static bool EmptyBinaryDirectory(const char *dir);
/*
+ * Write an initial CMakeCache.txt from the given contents.
+ */
+ static bool WriteInitialCache(const char* directory, const char* text);
+
+ /*
* Some elapsed time handling functions
*/
static void SleepInSeconds(unsigned int secondsToWait);