diff options
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r-- | Source/cmCTest.cxx | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 049248e..629282b 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1105,8 +1105,12 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output, //---------------------------------------------------------------------- int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, int *retVal, - std::ostream* log, double testTimeOut) + std::ostream* log, double testTimeOut, + std::vector<std::string>* environment) { + std::vector<std::string> origEnv; + bool modifyEnv = (environment && environment->size()>0); + // determine how much time we have double timeout = this->GetRemainingTimeAllowed() - 120; if (this->TimeOut && this->TimeOut < timeout) @@ -1156,6 +1160,11 @@ int cmCTest::RunTest(std::vector<const char*> argv, } std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory(); + if (modifyEnv) + { + origEnv = cmSystemTools::AppendEnv(environment); + } + *retVal = inst.Run(args, output); if ( *log ) { @@ -1166,6 +1175,12 @@ int cmCTest::RunTest(std::vector<const char*> argv, cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Internal cmCTest object used to run test." << std::endl << *output << std::endl); + + if (modifyEnv) + { + cmSystemTools::RestoreEnv(origEnv); + } + return cmsysProcess_State_Exited; } std::vector<char> tempOutput; @@ -1174,6 +1189,11 @@ int cmCTest::RunTest(std::vector<const char*> argv, *output = ""; } + if (modifyEnv) + { + origEnv = cmSystemTools::AppendEnv(environment); + } + cmsysProcess* cp = cmsysProcess_New(); cmsysProcess_SetCommand(cp, &*argv.begin()); cmCTestLog(this, DEBUG, "Command is: " << argv[0] << std::endl); @@ -1233,6 +1253,11 @@ int cmCTest::RunTest(std::vector<const char*> argv, } cmsysProcess_Delete(cp); + if (modifyEnv) + { + cmSystemTools::RestoreEnv(origEnv); + } + return result; } |