diff options
author | Craig Scott <craig.scott@crascit.com> | 2018-03-04 06:27:09 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2018-03-08 09:07:14 (GMT) |
commit | e60e4dfc88252aaec53f0d832508d41dff6165fd (patch) | |
tree | 5903e9e8f2eb57780d47a21d83f282f9cee11741 /Source/CTest/cmCTestBuildAndTestHandler.cxx | |
parent | e654622aee22655c418a9c663fad79243ca0c819 (diff) | |
download | CMake-e60e4dfc88252aaec53f0d832508d41dff6165fd.zip CMake-e60e4dfc88252aaec53f0d832508d41dff6165fd.tar.gz CMake-e60e4dfc88252aaec53f0d832508d41dff6165fd.tar.bz2 |
cmWorkingDirectory: Check success of current dir changes
Diffstat (limited to 'Source/CTest/cmCTestBuildAndTestHandler.cxx')
-rw-r--r-- | Source/CTest/cmCTestBuildAndTestHandler.cxx | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 2e1ea4c..b2c68e7 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -11,6 +11,7 @@ #include "cmsys/Process.h" #include <chrono> +#include <cstring> #include <ratio> #include <stdlib.h> @@ -196,6 +197,16 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) cmSystemTools::MakeDirectory(this->BinaryDir); } cmWorkingDirectory workdir(this->BinaryDir); + if (workdir.Failed()) { + auto msg = "Failed to change working directory to " + this->BinaryDir + + " : " + std::strerror(workdir.GetLastResult()) + "\n"; + if (outstring) { + *outstring = msg; + } else { + cmCTestLog(this->CTest, ERROR_MESSAGE, msg); + } + return 1; + } if (this->BuildNoCMake) { // Make the generator available for the Build call below. @@ -307,7 +318,16 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) // run the test from the this->BuildRunDir if set if (!this->BuildRunDir.empty()) { out << "Run test in directory: " << this->BuildRunDir << "\n"; - cmSystemTools::ChangeDirectory(this->BuildRunDir); + if (!workdir.SetDirectory(this->BuildRunDir)) { + out << "Failed to change working directory : " + << std::strerror(workdir.GetLastResult()) << "\n"; + if (outstring) { + *outstring = out.str(); + } else { + cmCTestLog(this->CTest, ERROR_MESSAGE, out.str()); + } + return 1; + } } out << "Running test command: \"" << fullPath << "\""; for (std::string const& testCommandArg : this->TestCommandArgs) { |