summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestBZR.cxx14
-rw-r--r--Source/CTest/cmCTestBZR.h8
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx14
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.h2
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx25
-rw-r--r--Source/CTest/cmCTestGIT.cxx12
-rw-r--r--Source/CTest/cmCTestGIT.h8
-rw-r--r--Source/CTest/cmCTestGlobalVC.cxx7
-rw-r--r--Source/CTest/cmCTestGlobalVC.h4
-rw-r--r--Source/CTest/cmCTestHG.cxx12
-rw-r--r--Source/CTest/cmCTestHG.h8
-rw-r--r--Source/CTest/cmCTestHandlerCommand.cxx9
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx11
-rw-r--r--Source/CTest/cmCTestP4.cxx16
-rw-r--r--Source/CTest/cmCTestP4.h8
-rw-r--r--Source/CTest/cmCTestRunTest.cxx19
-rw-r--r--Source/CTest/cmCTestSVN.cxx33
-rw-r--r--Source/CTest/cmCTestSVN.h12
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx13
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx70
-rw-r--r--Source/CTest/cmCTestUpdateHandler.cxx4
-rw-r--r--Source/CTest/cmCTestVC.cxx12
-rw-r--r--Source/CTest/cmCTestVC.h4
23 files changed, 157 insertions, 168 deletions
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx
index b42953b..6769ee5 100644
--- a/Source/CTest/cmCTestBZR.cxx
+++ b/Source/CTest/cmCTestBZR.cxx
@@ -151,22 +151,24 @@ std::string cmCTestBZR::LoadInfo()
return rev;
}
-void cmCTestBZR::NoteOldRevision()
+bool cmCTestBZR::NoteOldRevision()
{
this->OldRevision = this->LoadInfo();
this->Log << "Revision before update: " << this->OldRevision << "\n";
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
<< this->OldRevision << "\n");
this->PriorRev.Rev = this->OldRevision;
+ return true;
}
-void cmCTestBZR::NoteNewRevision()
+bool cmCTestBZR::NoteNewRevision()
{
this->NewRevision = this->LoadInfo();
this->Log << "Revision after update: " << this->NewRevision << "\n";
cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
<< this->NewRevision << "\n");
this->Log << "URL = " << this->URL << "\n";
+ return true;
}
class cmCTestBZR::LogParser : public cmCTestVC::OutputLogger,
@@ -386,7 +388,7 @@ bool cmCTestBZR::UpdateImpl()
return this->RunUpdateCommand(&bzr_update[0], &out, &err);
}
-void cmCTestBZR::LoadRevisions()
+bool cmCTestBZR::LoadRevisions()
{
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per revision):\n"
@@ -400,7 +402,7 @@ void cmCTestBZR::LoadRevisions()
// DoRevision takes care of discarding the information about OldRevision
revs = this->OldRevision + ".." + this->NewRevision;
} else {
- return;
+ return true;
}
// Run "bzr log" to get all global revisions of interest.
@@ -415,6 +417,7 @@ void cmCTestBZR::LoadRevisions()
this->RunChild(bzr_log, &out, &err);
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
+ return true;
}
class cmCTestBZR::StatusParser : public cmCTestVC::LineParser
@@ -460,7 +463,7 @@ private:
}
};
-void cmCTestBZR::LoadModifications()
+bool cmCTestBZR::LoadModifications()
{
// Run "bzr status" which reports local modifications.
const char* bzr = this->CommandLineTool.c_str();
@@ -468,4 +471,5 @@ void cmCTestBZR::LoadModifications()
StatusParser out(this, "status-out> ");
OutputLogger err(this->Log, "status-err> ");
this->RunChild(bzr_status, &out, &err);
+ return true;
}
diff --git a/Source/CTest/cmCTestBZR.h b/Source/CTest/cmCTestBZR.h
index e7af90b..0b62582 100644
--- a/Source/CTest/cmCTestBZR.h
+++ b/Source/CTest/cmCTestBZR.h
@@ -26,16 +26,16 @@ public:
private:
// Implement cmCTestVC internal API.
- void NoteOldRevision() CM_OVERRIDE;
- void NoteNewRevision() CM_OVERRIDE;
+ bool NoteOldRevision() CM_OVERRIDE;
+ bool NoteNewRevision() CM_OVERRIDE;
bool UpdateImpl() CM_OVERRIDE;
// URL of repository directory checked out in the working tree.
std::string URL;
std::string LoadInfo();
- void LoadModifications() CM_OVERRIDE;
- void LoadRevisions() CM_OVERRIDE;
+ bool LoadModifications() CM_OVERRIDE;
+ bool LoadRevisions() CM_OVERRIDE;
// Parsing helper classes.
class InfoParser;
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 6780a0e..6f81429 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -6,6 +6,7 @@
#include "cmCTestTestHandler.h"
#include "cmGlobalGenerator.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include "cmake.h"
#include <cmsys/Process.h>
@@ -42,7 +43,7 @@ int cmCTestBuildAndTestHandler::ProcessHandler()
int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
std::ostringstream& out,
std::string& cmakeOutString,
- std::string& cwd, cmake* cm)
+ cmake* cm)
{
unsigned int k;
std::vector<std::string> args;
@@ -85,8 +86,6 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
if (cm->Run(args) != 0) {
out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n";
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
if (outstring) {
*outstring = out.str();
} else {
@@ -99,8 +98,6 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
if (cm->Run(args) != 0) {
out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n";
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
if (outstring) {
*outstring = out.str();
} else {
@@ -199,13 +196,12 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
double clock_start = cmSystemTools::GetTime();
// make sure the binary dir is there
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
out << "Internal cmake changing into directory: " << this->BinaryDir
<< std::endl;
if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) {
cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
}
- cmSystemTools::ChangeDirectory(this->BinaryDir);
+ cmWorkingDirectory workdir(this->BinaryDir);
if (this->BuildNoCMake) {
// Make the generator available for the Build call below.
@@ -217,7 +213,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
cm.LoadCache(this->BinaryDir);
} else {
// do the cmake step, no timeout here since it is not a sub process
- if (this->RunCMake(outstring, out, cmakeOutString, cwd, &cm)) {
+ if (this->RunCMake(outstring, out, cmakeOutString, &cm)) {
return 1;
}
}
@@ -304,8 +300,6 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
} else {
cmCTestLog(this->CTest, ERROR_MESSAGE, out.str());
}
- // return to the original directory
- cmSystemTools::ChangeDirectory(cwd);
return 1;
}
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h
index 5885738..af082a3 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.h
+++ b/Source/CTest/cmCTestBuildAndTestHandler.h
@@ -46,7 +46,7 @@ protected:
///! Run CMake and build a test and then run it as a single test.
int RunCMakeAndTest(std::string* output);
int RunCMake(std::string* outstring, std::ostringstream& out,
- std::string& cmakeOutString, std::string& cwd, cmake* cm);
+ std::string& cmakeOutString, cmake* cm);
std::string Output;
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 989c096..120c5d9 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -12,6 +12,7 @@
#include "cmParseJacocoCoverage.h"
#include "cmParsePHPCoverage.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include "cmXMLWriter.h"
#include "cmake.h"
@@ -969,9 +970,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
std::string tempDir = testingDir + "/CoverageInfo";
- std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::MakeDirectory(tempDir.c_str());
- cmSystemTools::ChangeDirectory(tempDir);
+ cmWorkingDirectory workdir(tempDir);
int gcovStyle = 0;
@@ -1294,7 +1294,6 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
}
}
- cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
}
@@ -1340,7 +1339,6 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
return 0;
}
std::string testingDir = this->CTest->GetBinaryDir();
- std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
std::set<std::string> missingFiles;
@@ -1362,7 +1360,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
this->Quiet);
std::string fileDir = cmSystemTools::GetFilenamePath(*it);
- cmSystemTools::ChangeDirectory(fileDir);
+ cmWorkingDirectory workdir(fileDir);
std::string command = "\"" + lcovCommand + "\" " + lcovExtraFlags + " ";
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -1552,7 +1550,6 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
}
}
- cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
}
@@ -1591,13 +1588,8 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is
// used while compiling.
gl.RecurseThroughSymlinksOff();
- std::string prevBinaryDir;
std::string buildDir = this->CTest->GetCTestConfiguration("BuildDirectory");
- if (cmSystemTools::ChangeDirectory(buildDir)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Error changing directory to "
- << buildDir << std::endl);
- return false;
- }
+ cmWorkingDirectory workdir(buildDir);
// Run profmerge to merge all *.dyn files into dpi files
if (!cmSystemTools::RunSingleCommand("profmerge")) {
@@ -1605,11 +1597,9 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
return false;
}
- prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory();
-
// DPI file should appear in build directory
std::string daGlob;
- daGlob = prevBinaryDir;
+ daGlob = buildDir;
daGlob += "/*.dpi";
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" looking for dpi files in: " << daGlob << std::endl,
@@ -1646,11 +1636,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
std::string tempDir = testingDir + "/CoverageInfo";
- std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::MakeDirectory(tempDir.c_str());
- cmSystemTools::ChangeDirectory(tempDir);
-
- cmSystemTools::ChangeDirectory(currentDirectory);
std::vector<std::string>::iterator fileIt;
int file_count = 0;
@@ -1737,7 +1723,6 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
}
++file_count;
}
- cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
}
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index d30f6b3..9c53aa1 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -67,19 +67,21 @@ std::string cmCTestGIT::GetWorkingRevision()
return rev;
}
-void cmCTestGIT::NoteOldRevision()
+bool cmCTestGIT::NoteOldRevision()
{
this->OldRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
<< this->OldRevision << "\n");
this->PriorRev.Rev = this->OldRevision;
+ return true;
}
-void cmCTestGIT::NoteNewRevision()
+bool cmCTestGIT::NoteNewRevision()
{
this->NewRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
<< this->NewRevision << "\n");
+ return true;
}
std::string cmCTestGIT::FindGitDir()
@@ -607,7 +609,7 @@ private:
char const cmCTestGIT::CommitParser::SectionSep[SectionCount] = { '\n', '\n',
'\0' };
-void cmCTestGIT::LoadRevisions()
+bool cmCTestGIT::LoadRevisions()
{
// Use 'git rev-list ... | git diff-tree ...' to get revisions.
std::string range = this->OldRevision + ".." + this->NewRevision;
@@ -634,9 +636,10 @@ void cmCTestGIT::LoadRevisions()
out.Process("", 1);
cmsysProcess_Delete(cp);
+ return true;
}
-void cmCTestGIT::LoadModifications()
+bool cmCTestGIT::LoadModifications()
{
const char* git = this->CommandLineTool.c_str();
@@ -660,4 +663,5 @@ void cmCTestGIT::LoadModifications()
ci != out.Changes.end(); ++ci) {
this->DoModification(PathModified, ci->Path);
}
+ return true;
}
diff --git a/Source/CTest/cmCTestGIT.h b/Source/CTest/cmCTestGIT.h
index a655502..d5a1ee3 100644
--- a/Source/CTest/cmCTestGIT.h
+++ b/Source/CTest/cmCTestGIT.h
@@ -28,8 +28,8 @@ private:
unsigned int CurrentGitVersion;
unsigned int GetGitVersion();
std::string GetWorkingRevision();
- void NoteOldRevision() CM_OVERRIDE;
- void NoteNewRevision() CM_OVERRIDE;
+ bool NoteOldRevision() CM_OVERRIDE;
+ bool NoteNewRevision() CM_OVERRIDE;
bool UpdateImpl() CM_OVERRIDE;
std::string FindGitDir();
@@ -39,8 +39,8 @@ private:
bool UpdateByCustom(std::string const& custom);
bool UpdateInternal();
- void LoadRevisions() CM_OVERRIDE;
- void LoadModifications() CM_OVERRIDE;
+ bool LoadRevisions() CM_OVERRIDE;
+ bool LoadModifications() CM_OVERRIDE;
// "public" needed by older Sun compilers
public:
diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx
index 08af179..25294b5 100644
--- a/Source/CTest/cmCTestGlobalVC.cxx
+++ b/Source/CTest/cmCTestGlobalVC.cxx
@@ -102,14 +102,15 @@ void cmCTestGlobalVC::WriteXMLGlobal(cmXMLWriter& xml)
bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
{
+ bool result = true;
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per revision):\n"
" "
<< std::flush);
- this->LoadRevisions();
+ result = this->LoadRevisions() && result;
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
- this->LoadModifications();
+ result = this->LoadModifications() && result;
this->WriteXMLGlobal(xml);
@@ -119,5 +120,5 @@ bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
this->WriteXMLDirectory(xml, di->first, di->second);
}
- return true;
+ return result;
}
diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h
index 9a3757d..9fa5f21 100644
--- a/Source/CTest/cmCTestGlobalVC.h
+++ b/Source/CTest/cmCTestGlobalVC.h
@@ -64,8 +64,8 @@ protected:
virtual void DoRevision(Revision const& revision,
std::vector<Change> const& changes);
virtual void DoModification(PathStatus status, std::string const& path);
- virtual void LoadModifications() = 0;
- virtual void LoadRevisions() = 0;
+ virtual bool LoadModifications() = 0;
+ virtual bool LoadRevisions() = 0;
virtual void WriteXMLGlobal(cmXMLWriter& xml);
void WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx
index 8443c93..68ebd37 100644
--- a/Source/CTest/cmCTestHG.cxx
+++ b/Source/CTest/cmCTestHG.cxx
@@ -104,19 +104,21 @@ std::string cmCTestHG::GetWorkingRevision()
return rev;
}
-void cmCTestHG::NoteOldRevision()
+bool cmCTestHG::NoteOldRevision()
{
this->OldRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
<< this->OldRevision << "\n");
this->PriorRev.Rev = this->OldRevision;
+ return true;
}
-void cmCTestHG::NoteNewRevision()
+bool cmCTestHG::NoteNewRevision()
{
this->NewRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
<< this->NewRevision << "\n");
+ return true;
}
bool cmCTestHG::UpdateImpl()
@@ -262,7 +264,7 @@ private:
}
};
-void cmCTestHG::LoadRevisions()
+bool cmCTestHG::LoadRevisions()
{
// Use 'hg log' to get revisions in a xml format.
//
@@ -293,9 +295,10 @@ void cmCTestHG::LoadRevisions()
OutputLogger err(this->Log, "log-err> ");
this->RunChild(hg_log, &out, &err);
out.Process("</log>\n");
+ return true;
}
-void cmCTestHG::LoadModifications()
+bool cmCTestHG::LoadModifications()
{
// Use 'hg status' to get modified files.
const char* hg = this->CommandLineTool.c_str();
@@ -303,4 +306,5 @@ void cmCTestHG::LoadModifications()
StatusParser out(this, "status-out> ");
OutputLogger err(this->Log, "status-err> ");
this->RunChild(hg_status, &out, &err);
+ return true;
}
diff --git a/Source/CTest/cmCTestHG.h b/Source/CTest/cmCTestHG.h
index a81c347..63baba2 100644
--- a/Source/CTest/cmCTestHG.h
+++ b/Source/CTest/cmCTestHG.h
@@ -26,12 +26,12 @@ public:
private:
std::string GetWorkingRevision();
- void NoteOldRevision() CM_OVERRIDE;
- void NoteNewRevision() CM_OVERRIDE;
+ bool NoteOldRevision() CM_OVERRIDE;
+ bool NoteNewRevision() CM_OVERRIDE;
bool UpdateImpl() CM_OVERRIDE;
- void LoadRevisions() CM_OVERRIDE;
- void LoadModifications() CM_OVERRIDE;
+ bool LoadRevisions() CM_OVERRIDE;
+ bool LoadModifications() CM_OVERRIDE;
// Parsing helper classes.
class IdentifyParser;
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index a989b12..c99e450 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -6,6 +6,7 @@
#include "cmCTestGenericHandler.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include "cmake.h"
#include <sstream>
@@ -123,8 +124,8 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
if (capureCMakeError) {
this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR],
"-1");
- const char* err = this->GetError();
- if (err && !cmSystemTools::FindLastString(err, "unknown error.")) {
+ std::string const err = this->GetName() + " " + this->GetError();
+ if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) {
cmCTestLog(this->CTest, ERROR_MESSAGE, err << " error from command\n");
}
// return success because failure is recorded in CAPTURE_CMAKE_ERROR
@@ -216,8 +217,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX]));
}
}
- std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(
+ cmWorkingDirectory workdir(
this->CTest->GetCTestConfiguration("BuildDirectory"));
int res = handler->ProcessHandler();
if (this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) {
@@ -243,7 +243,6 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR],
returnString);
}
- cmSystemTools::ChangeDirectory(current_dir);
return true;
}
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index c1724ab..ff465ab 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -7,6 +7,7 @@
#include "cmCTestScriptHandler.h"
#include "cmCTestTestHandler.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include <algorithm>
#include <cmsys/FStream.hxx>
@@ -138,8 +139,7 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
}
}
- std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(this->Properties[test]->Directory);
+ cmWorkingDirectory workdir(this->Properties[test]->Directory);
// Lock the resources we'll be using
this->LockResources(test);
@@ -166,7 +166,6 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
this->Failed->push_back(this->Properties[test]->Name);
delete testRun;
}
- cmSystemTools::ChangeDirectory(current_dir);
}
void cmCTestMultiProcessHandler::LockResources(int index)
@@ -683,9 +682,7 @@ void cmCTestMultiProcessHandler::PrintTestList()
count++;
cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
- // push working dir
- std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(p.Directory);
+ cmWorkingDirectory workdir(p.Directory);
cmCTestRunTest testRun(this->TestHandler);
testRun.SetIndex(p.Index);
@@ -724,8 +721,6 @@ void cmCTestMultiProcessHandler::PrintTestList()
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, p.Name << std::endl,
this->Quiet);
- // pop working dir
- cmSystemTools::ChangeDirectory(current_dir);
}
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index 41b45a8..4f78876 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -369,24 +369,26 @@ std::string cmCTestP4::GetWorkingRevision()
return rev;
}
-void cmCTestP4::NoteOldRevision()
+bool cmCTestP4::NoteOldRevision()
{
this->OldRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
<< this->OldRevision << "\n");
this->PriorRev.Rev = this->OldRevision;
+ return true;
}
-void cmCTestP4::NoteNewRevision()
+bool cmCTestP4::NoteNewRevision()
{
this->NewRevision = this->GetWorkingRevision();
cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
<< this->NewRevision << "\n");
+ return true;
}
-void cmCTestP4::LoadRevisions()
+bool cmCTestP4::LoadRevisions()
{
std::vector<char const*> p4_changes;
SetP4Options(p4_changes);
@@ -399,7 +401,7 @@ void cmCTestP4::LoadRevisions()
if (this->OldRevision == "<unknown>" || this->NewRevision == "<unknown>") {
cmCTestLog(this->CTest, HANDLER_OUTPUT, " At least one of the revisions "
<< "is unknown. No repository changes will be reported.\n");
- return;
+ return false;
}
range.append("@")
@@ -418,7 +420,7 @@ void cmCTestP4::LoadRevisions()
this->RunChild(&p4_changes[0], &out, &err);
if (ChangeLists.empty()) {
- return;
+ return true;
}
// p4 describe -s ...@1111111,2222222
@@ -435,9 +437,10 @@ void cmCTestP4::LoadRevisions()
OutputLogger errDescribe(this->Log, "p4_describe-err> ");
this->RunChild(&p4_describe[0], &outDescribe, &errDescribe);
}
+ return true;
}
-void cmCTestP4::LoadModifications()
+bool cmCTestP4::LoadModifications()
{
std::vector<char const*> p4_diff;
SetP4Options(p4_diff);
@@ -453,6 +456,7 @@ void cmCTestP4::LoadModifications()
DiffParser out(this, "p4_diff-out> ");
OutputLogger err(this->Log, "p4_diff-err> ");
this->RunChild(&p4_diff[0], &out, &err);
+ return true;
}
bool cmCTestP4::UpdateCustom(const std::string& custom)
diff --git a/Source/CTest/cmCTestP4.h b/Source/CTest/cmCTestP4.h
index eadc4fb..2c04dc6 100644
--- a/Source/CTest/cmCTestP4.h
+++ b/Source/CTest/cmCTestP4.h
@@ -51,13 +51,13 @@ private:
void SetP4Options(std::vector<char const*>& options);
std::string GetWorkingRevision();
- void NoteOldRevision() CM_OVERRIDE;
- void NoteNewRevision() CM_OVERRIDE;
+ bool NoteOldRevision() CM_OVERRIDE;
+ bool NoteNewRevision() CM_OVERRIDE;
bool UpdateImpl() CM_OVERRIDE;
bool UpdateCustom(const std::string& custom);
- void LoadRevisions() CM_OVERRIDE;
- void LoadModifications() CM_OVERRIDE;
+ bool LoadRevisions() CM_OVERRIDE;
+ bool LoadModifications() CM_OVERRIDE;
class ChangesParser;
class DescribeParser;
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index ac1644f..f148f30 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -7,6 +7,7 @@
#include "cmCTestTestHandler.h"
#include "cmProcess.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include <cmConfigure.h>
#include <cm_curl.h>
@@ -270,14 +271,11 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
*this->TestHandler->LogFile << "Test time = " << buf << std::endl;
}
- // Set the working directory to the tests directory
- std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(this->TestProperties->Directory);
-
- this->DartProcessing();
-
- // restore working directory
- cmSystemTools::ChangeDirectory(oldpath);
+ // Set the working directory to the tests directory to process Dart files.
+ {
+ cmWorkingDirectory workdir(this->TestProperties->Directory);
+ this->DartProcessing();
+ }
// if this is doing MemCheck then all the output needs to be put into
// Output since that is what is parsed by cmCTestMemCheckHandler
@@ -356,11 +354,8 @@ bool cmCTestRunTest::StartAgain()
}
this->RunAgain = false; // reset
// change to tests directory
- std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(this->TestProperties->Directory);
+ cmWorkingDirectory workdir(this->TestProperties->Directory);
this->StartTest(this->TotalNumberOfTests);
- // change back
- cmSystemTools::ChangeDirectory(current_dir);
return true;
}
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index 410e0d4..ce395cd 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -97,9 +97,11 @@ std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo)
return rev;
}
-void cmCTestSVN::NoteOldRevision()
+bool cmCTestSVN::NoteOldRevision()
{
- this->LoadRepositories();
+ if (!this->LoadRepositories()) {
+ return false;
+ }
std::list<SVNInfo>::iterator itbeg = this->Repositories.begin();
std::list<SVNInfo>::iterator itend = this->Repositories.end();
@@ -116,11 +118,14 @@ void cmCTestSVN::NoteOldRevision()
// Set the global old revision to the one of the root
this->OldRevision = this->RootInfo->OldRevision;
this->PriorRev.Rev = this->OldRevision;
+ return true;
}
-void cmCTestSVN::NoteNewRevision()
+bool cmCTestSVN::NoteNewRevision()
{
- this->LoadRepositories();
+ if (!this->LoadRepositories()) {
+ return false;
+ }
std::list<SVNInfo>::iterator itbeg = this->Repositories.begin();
std::list<SVNInfo>::iterator itend = this->Repositories.end();
@@ -153,6 +158,7 @@ void cmCTestSVN::NoteNewRevision()
// Set the global new revision to the one of the root
this->NewRevision = this->RootInfo->NewRevision;
+ return true;
}
void cmCTestSVN::GuessBase(SVNInfo& svninfo,
@@ -370,18 +376,20 @@ private:
}
};
-void cmCTestSVN::LoadRevisions()
+bool cmCTestSVN::LoadRevisions()
{
+ bool result = true;
// Get revisions for all the external repositories
std::list<SVNInfo>::iterator itbeg = this->Repositories.begin();
std::list<SVNInfo>::iterator itend = this->Repositories.end();
for (; itbeg != itend; itbeg++) {
SVNInfo& svninfo = *itbeg;
- LoadRevisions(svninfo);
+ result = this->LoadRevisions(svninfo) && result;
}
+ return result;
}
-void cmCTestSVN::LoadRevisions(SVNInfo& svninfo)
+bool cmCTestSVN::LoadRevisions(SVNInfo& svninfo)
{
// We are interested in every revision included in the update.
std::string revs;
@@ -400,7 +408,7 @@ void cmCTestSVN::LoadRevisions(SVNInfo& svninfo)
svn_log.push_back(svninfo.LocalPath.c_str());
LogParser out(this, "log-out> ", svninfo);
OutputLogger err(this->Log, "log-err> ");
- this->RunSVNCommand(svn_log, &out, &err);
+ return this->RunSVNCommand(svn_log, &out, &err);
}
void cmCTestSVN::DoRevisionSVN(Revision const& revision,
@@ -468,7 +476,7 @@ private:
}
};
-void cmCTestSVN::LoadModifications()
+bool cmCTestSVN::LoadModifications()
{
// Run "svn status" which reports local modifications.
std::vector<const char*> svn_status;
@@ -476,6 +484,7 @@ void cmCTestSVN::LoadModifications()
StatusParser out(this, "status-out> ");
OutputLogger err(this->Log, "status-err> ");
this->RunSVNCommand(svn_status, &out, &err);
+ return true;
}
void cmCTestSVN::WriteXMLGlobal(cmXMLWriter& xml)
@@ -521,10 +530,10 @@ private:
}
};
-void cmCTestSVN::LoadRepositories()
+bool cmCTestSVN::LoadRepositories()
{
if (!this->Repositories.empty()) {
- return;
+ return true;
}
// Info for root repository
@@ -536,7 +545,7 @@ void cmCTestSVN::LoadRepositories()
svn_status.push_back("status");
ExternalParser out(this, "external-out> ");
OutputLogger err(this->Log, "external-err> ");
- this->RunSVNCommand(svn_status, &out, &err);
+ return this->RunSVNCommand(svn_status, &out, &err);
}
std::string cmCTestSVN::SVNInfo::BuildLocalPath(std::string const& path) const
diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h
index c0348c2..e5fe5b7 100644
--- a/Source/CTest/cmCTestSVN.h
+++ b/Source/CTest/cmCTestSVN.h
@@ -30,8 +30,8 @@ public:
private:
// Implement cmCTestVC internal API.
void CleanupImpl() CM_OVERRIDE;
- void NoteOldRevision() CM_OVERRIDE;
- void NoteNewRevision() CM_OVERRIDE;
+ bool NoteOldRevision() CM_OVERRIDE;
+ bool NoteNewRevision() CM_OVERRIDE;
bool UpdateImpl() CM_OVERRIDE;
bool RunSVNCommand(std::vector<char const*> const& parameters,
@@ -77,10 +77,10 @@ private:
SVNInfo* RootInfo;
std::string LoadInfo(SVNInfo& svninfo);
- void LoadRepositories();
- void LoadModifications() CM_OVERRIDE;
- void LoadRevisions() CM_OVERRIDE;
- void LoadRevisions(SVNInfo& svninfo);
+ bool LoadRepositories();
+ bool LoadModifications() CM_OVERRIDE;
+ bool LoadRevisions() CM_OVERRIDE;
+ bool LoadRevisions(SVNInfo& svninfo);
void GuessBase(SVNInfo& svninfo, std::vector<Change> const& changes);
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 5e5119d..cc399b0 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -19,6 +19,7 @@
#include "cmState.h"
#include "cmSystemTools.h"
#include "cmThirdParty.h"
+#include "cmWorkingDirectory.h"
#include "cmXMLParser.h"
#include "cmake.h"
@@ -1519,7 +1520,6 @@ int cmCTestSubmitHandler::ProcessHandler()
#endif
} else if (dropMethod == "scp") {
std::string url;
- std::string oldWorkingDirectory;
if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@";
}
@@ -1528,19 +1528,16 @@ int cmCTestSubmitHandler::ProcessHandler()
// change to the build directory so that we can uses a relative path
// on windows since scp dosn't support "c:" a drive in the path
- oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(buildDirectory);
+ cmWorkingDirectory workdir(buildDirectory);
if (!this->SubmitUsingSCP(this->CTest->GetCTestConfiguration("ScpCommand"),
"Testing/" + this->CTest->GetCurrentTag(), files,
prefix, url)) {
- cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Problems when submitting via SCP" << std::endl);
ofs << " Problems when submitting via SCP" << std::endl;
return -1;
}
- cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
" Submission successful" << std::endl, this->Quiet);
ofs << " Submission successful" << std::endl;
@@ -1550,22 +1547,18 @@ int cmCTestSubmitHandler::ProcessHandler()
// change to the build directory so that we can uses a relative path
// on windows since scp dosn't support "c:" a drive in the path
- std::string oldWorkingDirectory =
- cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(buildDirectory);
+ cmWorkingDirectory workdir(buildDirectory);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" Change directory: " << buildDirectory << std::endl,
this->Quiet);
if (!this->SubmitUsingCP("Testing/" + this->CTest->GetCurrentTag(), files,
prefix, location)) {
- cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Problems when submitting via CP" << std::endl);
ofs << " Problems when submitting via cp" << std::endl;
return -1;
}
- cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
" Submission successful" << std::endl, this->Quiet);
ofs << " Submission successful" << std::endl;
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 6175e50..9d22065 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -27,6 +27,7 @@
#include "cmState.h"
#include "cmStateSnapshot.h"
#include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
#include "cmXMLWriter.h"
#include "cm_auto_ptr.hxx"
#include "cm_utf8.h"
@@ -86,22 +87,24 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
// No subdirectory? So what...
continue;
}
- cmSystemTools::ChangeDirectory(fname);
- const char* testFilename;
- if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
- // does the CTestTestfile.cmake exist ?
- testFilename = "CTestTestfile.cmake";
- } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
- // does the DartTestfile.txt exist ?
- testFilename = "DartTestfile.txt";
- } else {
- // No CTestTestfile? Who cares...
- continue;
+ bool readit = false;
+ {
+ cmWorkingDirectory workdir(fname);
+ const char* testFilename;
+ if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
+ // does the CTestTestfile.cmake exist ?
+ testFilename = "CTestTestfile.cmake";
+ } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
+ // does the DartTestfile.txt exist ?
+ testFilename = "DartTestfile.txt";
+ } else {
+ // No CTestTestfile? Who cares...
+ continue;
+ }
+ fname += "/";
+ fname += testFilename;
+ readit = this->Makefile->ReadDependentFile(fname.c_str());
}
- fname += "/";
- fname += testFilename;
- bool readit = this->Makefile->ReadDependentFile(fname.c_str());
- cmSystemTools::ChangeDirectory(cwd);
if (!readit) {
std::string m = "Could not find include file: ";
m += fname;
@@ -109,7 +112,6 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
return false;
}
}
- cmSystemTools::ChangeDirectory(cwd);
return true;
}
@@ -149,9 +151,7 @@ bool cmCTestAddSubdirectoryCommand::InitialPass(
return false;
}
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(cwd);
- std::string fname = cwd;
+ std::string fname = cmSystemTools::GetCurrentWorkingDirectory();
fname += "/";
fname += args[0];
@@ -159,23 +159,23 @@ bool cmCTestAddSubdirectoryCommand::InitialPass(
// No subdirectory? So what...
return true;
}
- cmSystemTools::ChangeDirectory(fname);
- const char* testFilename;
- if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
- // does the CTestTestfile.cmake exist ?
- testFilename = "CTestTestfile.cmake";
- } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
- // does the DartTestfile.txt exist ?
- testFilename = "DartTestfile.txt";
- } else {
- // No CTestTestfile? Who cares...
- cmSystemTools::ChangeDirectory(cwd);
- return true;
+ bool readit = false;
+ {
+ const char* testFilename;
+ if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
+ // does the CTestTestfile.cmake exist ?
+ testFilename = "CTestTestfile.cmake";
+ } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
+ // does the DartTestfile.txt exist ?
+ testFilename = "DartTestfile.txt";
+ } else {
+ // No CTestTestfile? Who cares...
+ return true;
+ }
+ fname += "/";
+ fname += testFilename;
+ readit = this->Makefile->ReadDependentFile(fname.c_str());
}
- fname += "/";
- fname += testFilename;
- bool readit = this->Makefile->ReadDependentFile(fname.c_str());
- cmSystemTools::ChangeDirectory(cwd);
if (!readit) {
std::string m = "Could not find include file: ";
m += fname;
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index 0998d59..2b5683a 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -198,7 +198,7 @@ int cmCTestUpdateHandler::ProcessHandler()
xml.Element("UpdateType",
cmCTestUpdateHandlerUpdateToString(this->UpdateType));
- vc->WriteXML(xml);
+ bool loadedMods = vc->WriteXML(xml);
int localModifications = 0;
int numUpdated = vc->GetPathCount(cmCTestVC::PathUpdated);
@@ -246,7 +246,7 @@ int cmCTestUpdateHandler::ProcessHandler()
xml.EndElement(); // UpdateReturnStatus
xml.EndElement(); // Update
xml.EndDocument();
- return updated ? numUpdated : -1;
+ return updated && loadedMods ? numUpdated : -1;
}
int cmCTestUpdateHandler::DetectVCS(const char* dir)
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index 444c43d..26c9bb5 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -147,23 +147,25 @@ bool cmCTestVC::Update()
// just note the current version and finish
if (!cmSystemTools::IsOn(
this->CTest->GetCTestConfiguration("UpdateVersionOnly").c_str())) {
- this->NoteOldRevision();
+ result = this->NoteOldRevision() && result;
this->Log << "--- Begin Update ---\n";
- result = this->UpdateImpl();
+ result = this->UpdateImpl() && result;
this->Log << "--- End Update ---\n";
}
- this->NoteNewRevision();
+ result = this->NoteNewRevision() && result;
return result;
}
-void cmCTestVC::NoteOldRevision()
+bool cmCTestVC::NoteOldRevision()
{
// We do nothing by default.
+ return true;
}
-void cmCTestVC::NoteNewRevision()
+bool cmCTestVC::NoteNewRevision()
{
// We do nothing by default.
+ return true;
}
bool cmCTestVC::UpdateImpl()
diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h
index 2681ba0..a1c1673 100644
--- a/Source/CTest/cmCTestVC.h
+++ b/Source/CTest/cmCTestVC.h
@@ -67,9 +67,9 @@ public:
protected:
// Internal API to be implemented by subclasses.
virtual void CleanupImpl();
- virtual void NoteOldRevision();
+ virtual bool NoteOldRevision();
virtual bool UpdateImpl();
- virtual void NoteNewRevision();
+ virtual bool NoteNewRevision();
virtual bool WriteXMLUpdates(cmXMLWriter& xml);
#if defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x510