diff options
Diffstat (limited to 'Source/CTest/cmCTestVC.cxx')
-rw-r--r-- | Source/CTest/cmCTestVC.cxx | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index cbbb5a5..609ccba 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -7,9 +7,10 @@ #include <sstream> #include <vector> +#include "cmsys/Process.h" + #include "cmCTest.h" #include "cmSystemTools.h" -#include "cmUVProcessChain.h" #include "cmValue.h" #include "cmXMLWriter.h" @@ -54,12 +55,18 @@ bool cmCTestVC::InitialCheckout(const std::string& command) // Construct the initial checkout command line. std::vector<std::string> args = cmSystemTools::ParseArguments(command); + std::vector<char const*> vc_co; + vc_co.reserve(args.size() + 1); + for (std::string const& arg : args) { + vc_co.push_back(arg.c_str()); + } + vc_co.push_back(nullptr); // Run the initial checkout command and log its output. this->Log << "--- Begin Initial Checkout ---\n"; OutputLogger out(this->Log, "co-out> "); OutputLogger err(this->Log, "co-err> "); - bool result = this->RunChild(args, &out, &err, parent); + bool result = this->RunChild(vc_co.data(), &out, &err, parent.c_str()); this->Log << "--- End Initial Checkout ---\n"; if (!result) { cmCTestLog(this->CTest, ERROR_MESSAGE, @@ -68,35 +75,35 @@ bool cmCTestVC::InitialCheckout(const std::string& command) return result; } -bool cmCTestVC::RunChild(const std::vector<std::string>& cmd, - OutputParser* out, OutputParser* err, - std::string workDir, Encoding encoding) +bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out, + OutputParser* err, const char* workDir, + Encoding encoding) { this->Log << cmCTestVC::ComputeCommandLine(cmd) << "\n"; - cmUVProcessChainBuilder builder; - if (workDir.empty()) { - workDir = this->SourceDirectory; - } - builder.AddCommand(cmd).SetWorkingDirectory(workDir); - auto status = cmCTestVC::RunProcess(builder, out, err, encoding); - return status.front().SpawnResult == 0 && status.front().ExitStatus == 0; + cmsysProcess* cp = cmsysProcess_New(); + cmsysProcess_SetCommand(cp, cmd); + workDir = workDir ? workDir : this->SourceDirectory.c_str(); + cmsysProcess_SetWorkingDirectory(cp, workDir); + cmCTestVC::RunProcess(cp, out, err, encoding); + int result = cmsysProcess_GetExitValue(cp); + cmsysProcess_Delete(cp); + return result == 0; } -std::string cmCTestVC::ComputeCommandLine(const std::vector<std::string>& cmd) +std::string cmCTestVC::ComputeCommandLine(char const* const* cmd) { std::ostringstream line; const char* sep = ""; - for (auto const& arg : cmd) { - line << sep << "\"" << arg << "\""; + for (const char* const* arg = cmd; *arg; ++arg) { + line << sep << "\"" << *arg << "\""; sep = " "; } return line.str(); } -bool cmCTestVC::RunUpdateCommand(const std::vector<std::string>& cmd, - OutputParser* out, OutputParser* err, - Encoding encoding) +bool cmCTestVC::RunUpdateCommand(char const* const* cmd, OutputParser* out, + OutputParser* err, Encoding encoding) { // Report the command line. this->UpdateCommandLine = this->ComputeCommandLine(cmd); @@ -106,7 +113,7 @@ bool cmCTestVC::RunUpdateCommand(const std::vector<std::string>& cmd, } // Run the command. - return this->RunChild(cmd, out, err, "", encoding); + return this->RunChild(cmd, out, err, nullptr, encoding); } std::string cmCTestVC::GetNightlyTime() |