Preserve environment variables across calls to cmCTestScriptHandler::RunConfigurationScript. This will help prevent problems like we are currently experiencing (regarding CMake continuous dashboards only running once each day because the HOME environment variable is modified indirectly by a command in a called script, but affects the environment in the calling script).

This commit is contained in:
David Cole 2009-12-23 14:34:46 -05:00
parent 68ed752b7d
commit 4d3a387ac6
3 changed files with 30 additions and 0 deletions

View File

@ -583,6 +583,10 @@ void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait)
int cmCTestScriptHandler::RunConfigurationScript
(const std::string& total_script_arg, bool pscope)
{
#ifdef CMAKE_BUILD_WITH_CMAKE
cmSystemTools::SaveRestoreEnvironment sre;
#endif
int result;
this->ScriptStartTime =

View File

@ -1673,6 +1673,18 @@ void cmSystemTools::RestoreEnv(const std::vector<std::string>& env)
PutEnv(eit->c_str());
}
}
//----------------------------------------------------------------------
cmSystemTools::SaveRestoreEnvironment::SaveRestoreEnvironment()
{
this->Env = cmSystemTools::GetEnvironmentVariables();
}
//----------------------------------------------------------------------
cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment()
{
cmSystemTools::RestoreEnv(this->Env);
}
#endif
void cmSystemTools::EnableVSConsoleOutput()

View File

@ -358,6 +358,20 @@ public:
AppendEnv to put the environment back to the way it
was. */
static void RestoreEnv(const std::vector<std::string>& env);
/** Helper class to save and restore the environment.
Instantiate this class as an automatic variable on
the stack. Its constructor saves a copy of the current
environment and then its destructor restores the
original environment. */
class SaveRestoreEnvironment
{
public:
SaveRestoreEnvironment();
virtual ~SaveRestoreEnvironment();
private:
std::vector<std::string> Env;
};
#endif
/** Setup the environment to enable VS 8 IDE output. */