CTest: Simplify environment save/restore

Replace use of AppendEnv/RestoreEnv pairs with instances of
SaveRestoreEnvironment.  Simplify the signature of AppendEnv and use it
in place of similar loops elsewhere.  Move the RestoreEnv implementation
inside the SaveRestoreEnvironment destructor which is the only place
left that calls it.
This commit is contained in:
Brad King
2012-04-24 16:24:17 -04:00
parent 93e6069553
commit b10c5cbb87
5 changed files with 34 additions and 74 deletions
+2 -10
View File
@@ -371,16 +371,8 @@ public:
/** Get the list of all environment variables */
static std::vector<std::string> GetEnvironmentVariables();
/** Append multiple variables to the current environment.
Return the original environment, as it was before the
append. */
static std::vector<std::string> AppendEnv(
std::vector<std::string>* env);
/** Restore the full environment to "env" - use after
AppendEnv to put the environment back to the way it
was. */
static void RestoreEnv(const std::vector<std::string>& env);
/** Append multiple variables to the current environment. */
static void AppendEnv(std::vector<std::string> const& env);
/** Helper class to save and restore the environment.
Instantiate this class as an automatic variable on