summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestBuildAndTestHandler.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2017-03-01 18:41:50 (GMT)
committerBrad King <brad.king@kitware.com>2017-03-06 15:38:58 (GMT)
commitaba92ffd92bb1cc4bbe898b7abe65347b0468d33 (patch)
tree7fff657ef3fe0dd115886283b808025cfa8faa34 /Source/CTest/cmCTestBuildAndTestHandler.cxx
parent047a5e4d6656f362151b855b34c259708b8419ba (diff)
downloadCMake-aba92ffd92bb1cc4bbe898b7abe65347b0468d33.zip
CMake-aba92ffd92bb1cc4bbe898b7abe65347b0468d33.tar.gz
CMake-aba92ffd92bb1cc4bbe898b7abe65347b0468d33.tar.bz2
cmWorkingDirectory: use the new class
These functions just need to change the directory for a block of code and then go back to the caller's expected location. Use cmWorkingDirectory to ensure that all return paths are handled.
Diffstat (limited to 'Source/CTest/cmCTestBuildAndTestHandler.cxx')
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx14
1 files changed, 4 insertions, 10 deletions
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;
}