diff options
| author | vladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925> | 2011-10-05 05:51:10 +0000 | 
|---|---|---|
| committer | vladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925> | 2011-10-05 05:51:10 +0000 | 
| commit | 69a40b7d4ab4171cbe4ef920e7a5171109e2064c (patch) | |
| tree | f5bc8a2924ea70d5edf2cfb2bbd39c02bf0c8d68 /src | |
| parent | 879916a9393ef4af84ebe8b331220586dd8cafbb (diff) | |
| download | googletest-69a40b7d4ab4171cbe4ef920e7a5171109e2064c.tar.gz googletest-69a40b7d4ab4171cbe4ef920e7a5171109e2064c.tar.bz2 googletest-69a40b7d4ab4171cbe4ef920e7a5171109e2064c.zip | |
Adds ability to inject death test child arguments for test purposes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/gtest-death-test.cc | 7 | ||||
| -rw-r--r-- | src/gtest-port.cc | 18 | 
2 files changed, 21 insertions, 4 deletions
| diff --git a/src/gtest-death-test.cc b/src/gtest-death-test.cc index 2f0b0e38..76aa1685 100644 --- a/src/gtest-death-test.cc +++ b/src/gtest-death-test.cc @@ -844,6 +844,11 @@ class ExecDeathTest : public ForkingDeathTest {        ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }    virtual TestRole AssumeRole();   private: +  static ::std::vector<testing::internal::string> +  GetArgvsForDeathTestChildProcess() { +    ::std::vector<testing::internal::string> args = GetInjectableArgvs(); +    return args; +  }    // The name of the file in which the death test is located.    const char* const file_;    // The line number on which the death test is located. @@ -1082,7 +1087,7 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() {                       GTEST_FLAG_PREFIX_, kInternalRunDeathTestFlag,                       file_, line_, death_test_index, pipe_fd[1]);    Arguments args; -  args.AddArguments(GetArgvs()); +  args.AddArguments(GetArgvsForDeathTestChildProcess());    args.AddArgument(filter_flag.c_str());    args.AddArgument(internal_flag.c_str()); diff --git a/src/gtest-port.cc b/src/gtest-port.cc index 32069146..6e8dca29 100644 --- a/src/gtest-port.cc +++ b/src/gtest-port.cc @@ -653,11 +653,23 @@ String GetCapturedStderr() { return GetCapturedStream(&g_captured_stderr); }  #if GTEST_HAS_DEATH_TEST  // A copy of all command line arguments.  Set by InitGoogleTest(). -::std::vector<String> g_argvs; +::std::vector<testing::internal::string> g_argvs; -// Returns the command line as a vector of strings. -const ::std::vector<String>& GetArgvs() { return g_argvs; } +static const ::std::vector<testing::internal::string>* g_injected_test_argvs = +                                        NULL;  // Owned. +void SetInjectableArgvs(const ::std::vector<testing::internal::string>* argvs) { +  if (g_injected_test_argvs != argvs) +    delete g_injected_test_argvs; +  g_injected_test_argvs = argvs; +} + +const ::std::vector<testing::internal::string>& GetInjectableArgvs() { +  if (g_injected_test_argvs != NULL) { +    return *g_injected_test_argvs; +  } +  return g_argvs; +}  #endif  // GTEST_HAS_DEATH_TEST  #if GTEST_OS_WINDOWS_MOBILE | 
