diff options
-rw-r--r-- | base/test/launcher/test_launcher.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/base/test/launcher/test_launcher.cc b/base/test/launcher/test_launcher.cc index f7f9679..08a573b 100644 --- a/base/test/launcher/test_launcher.cc +++ b/base/test/launcher/test_launcher.cc @@ -166,6 +166,18 @@ bool TakeInt32FromEnvironment(const char* const var, int32* result) { return true; } +// Unsets the environment variable |name| and returns true on success. +// Also returns true if the variable just doesn't exist. +bool UnsetEnvironmentVariableIfExists(const std::string& name) { + scoped_ptr<Environment> env(Environment::Create()); + std::string str_val; + + if (!env->GetVar(name.c_str(), &str_val)) + return true; + + return env->UnSetVar(name.c_str()); +} + // For a basic pattern matching for gtest_filter options. (Copied from // gtest.cc, see the comment below and http://crbug.com/44497) bool PatternMatchesString(const char* pattern, const char* str) { @@ -616,6 +628,11 @@ bool TestLauncher::Init() { return false; } + // Make sure we don't pass any sharding-related environment to the child + // processes. This test launcher implements the sharding completely. + CHECK(UnsetEnvironmentVariableIfExists("GTEST_TOTAL_SHARDS")); + CHECK(UnsetEnvironmentVariableIfExists("GTEST_SHARD_INDEX")); + if (command_line->HasSwitch(kGTestRepeatFlag) && !StringToInt(command_line->GetSwitchValueASCII(kGTestRepeatFlag), &cycles_)) { |