| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 42070ca commit a1817f5
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2308,7 +2308,8 @@ TestInfo* RegisterTest(const char* test_suite_name, const char* test_name, | |||
| 2308 | 2308 | // tests are successful, or 1 otherwise. | |
| 2309 | 2309 | // | |
| 2310 | 2310 | // RUN_ALL_TESTS() should be invoked after the command line has been | |
| 2311 | - // parsed by InitGoogleTest(). | ||
| 2311 | + // parsed by InitGoogleTest(). RUN_ALL_TESTS will tear down and delete any | ||
| 2312 | + // installed environments and should only be called once per binary. | ||
| 2312 | 2313 | // | |
| 2313 | 2314 | // This function was formerly a macro; thus, it is in the global | |
| 2314 | 2315 | // namespace and has an all-caps name. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -71,7 +71,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ | |||
| 71 | 71 | // | |
| 72 | 72 | // exit status: The integer exit information in the format specified | |
| 73 | 73 | // by wait(2) | |
| 74 | - // exit code: The integer code passed to exit(3), _exit(2), or | ||
| 74 | + // exit code: The integer code passed to exit(3), _Exit(2), or | ||
| 75 | 75 | // returned from main() | |
| 76 | 76 | class GTEST_API_ DeathTest { | |
| 77 | 77 | public: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,8 @@ | |||
| 32 | 32 | ||
| 33 | 33 | #include "gtest/gtest-death-test.h" | |
| 34 | 34 | ||
| 35 | + #include <stdlib.h> | ||
| 36 | + | ||
| 35 | 37 | #include <functional> | |
| 36 | 38 | #include <memory> | |
| 37 | 39 | #include <sstream> | |
@@ -115,7 +117,7 @@ GTEST_DEFINE_string_( | |||
| 115 | 117 | GTEST_DEFINE_bool_( | |
| 116 | 118 | death_test_use_fork, | |
| 117 | 119 | testing::internal::BoolFromGTestEnv("death_test_use_fork", false), | |
| 118 | - "Instructs to use fork()/_exit() instead of clone() in death tests. " | ||
| 120 | + "Instructs to use fork()/_Exit() instead of clone() in death tests. " | ||
| 119 | 121 | "Ignored and always uses fork() on POSIX systems where clone() is not " | |
| 120 | 122 | "implemented. Useful when running under valgrind or similar tools if " | |
| 121 | 123 | "those do not support clone(). Valgrind 3.3.1 will just fail if " | |
@@ -299,7 +301,7 @@ enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW }; | |||
| 299 | 301 | fputc(kDeathTestInternalError, parent); | |
| 300 | 302 | fprintf(parent, "%s", message.c_str()); | |
| 301 | 303 | fflush(parent); | |
| 302 | - _exit(1); | ||
| 304 | + _Exit(1); | ||
| 303 | 305 | } else { | |
| 304 | 306 | fprintf(stderr, "%s", message.c_str()); | |
| 305 | 307 | fflush(stderr); | |
@@ -511,7 +513,7 @@ std::string DeathTestImpl::GetErrorLogs() { return GetCapturedStderr(); } | |||
| 511 | 513 | // Signals that the death test code which should have exited, didn't. | |
| 512 | 514 | // Should be called only in a death test child process. | |
| 513 | 515 | // Writes a status byte to the child's status file descriptor, then | |
| 514 | - // calls _exit(1). | ||
| 516 | + // calls _Exit(1). | ||
| 515 | 517 | void DeathTestImpl::Abort(AbortReason reason) { | |
| 516 | 518 | // The parent process considers the death test to be a failure if | |
| 517 | 519 | // it finds any data in our pipe. So, here we write a single flag byte | |
@@ -523,13 +525,13 @@ void DeathTestImpl::Abort(AbortReason reason) { | |||
| 523 | 525 | GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1)); | |
| 524 | 526 | // We are leaking the descriptor here because on some platforms (i.e., | |
| 525 | 527 | // when built as Windows DLL), destructors of global objects will still | |
| 526 | - // run after calling _exit(). On such systems, write_fd_ will be | ||
| 528 | + // run after calling _Exit(). On such systems, write_fd_ will be | ||
| 527 | 529 | // indirectly closed from the destructor of UnitTestImpl, causing double | |
| 528 | 530 | // close if it is also closed here. On debug configurations, double close | |
| 529 | 531 | // may assert. As there are no in-process buffers to flush here, we are | |
| 530 | 532 | // relying on the OS to close the descriptor after the process terminates | |
| 531 | 533 | // when the destructors are not run. | |
| 532 | - _exit(1); // Exits w/o any normal exit hooks (we were supposed to crash) | ||
| 534 | + _Exit(1); // Exits w/o any normal exit hooks (we were supposed to crash) | ||
| 533 | 535 | } | |
| 534 | 536 | ||
| 535 | 537 | // Returns an indented copy of stderr output for a death test. | |
@@ -1333,7 +1335,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) { | |||
| 1333 | 1335 | #endif // GTEST_HAS_CLONE | |
| 1334 | 1336 | ||
| 1335 | 1337 | if (use_fork && (child_pid = fork()) == 0) { | |
| 1336 | - _exit(ExecDeathTestChildMain(&args)); | ||
| 1338 | + _Exit(ExecDeathTestChildMain(&args)); | ||
| 1337 | 1339 | } | |
| 1338 | 1340 | #endif // GTEST_OS_QNX | |
| 1339 | 1341 | #ifdef GTEST_OS_LINUX | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -536,7 +536,8 @@ void InsertSyntheticTestCase(const std::string& name, CodeLocation location, | |||
| 536 | 536 | if (ignored.find(name) != ignored.end()) return; | |
| 537 | 537 | ||
| 538 | 538 | const char kMissingInstantiation[] = // | |
| 539 | - " is defined via TEST_P, but never instantiated. None of the test cases " | ||
| 539 | + " is defined via TEST_P, but never instantiated. None of the test " | ||
| 540 | + "cases " | ||
| 540 | 541 | "will run. Either no INSTANTIATE_TEST_SUITE_P is provided or the only " | |
| 541 | 542 | "ones provided expand to nothing." | |
| 542 | 543 | "\n\n" | |
@@ -615,10 +616,12 @@ void TypeParameterizedTestSuiteRegistry::CheckForInstantiations() { | |||
| 615 | 616 | "\n\n" | |
| 616 | 617 | "Ideally, TYPED_TEST_P definitions should only ever be included as " | |
| 617 | 618 | "part of binaries that intend to use them. (As opposed to, for " | |
| 618 | - "example, being placed in a library that may be linked in to get other " | ||
| 619 | + "example, being placed in a library that may be linked in to get " | ||
| 620 | + "other " | ||
| 619 | 621 | "utilities.)" | |
| 620 | 622 | "\n\n" | |
| 621 | - "To suppress this error for this test suite, insert the following line " | ||
| 623 | + "To suppress this error for this test suite, insert the following " | ||
| 624 | + "line " | ||
| 622 | 625 | "(in a non-header) in the namespace it is defined in:" | |
| 623 | 626 | "\n\n" | |
| 624 | 627 | "GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(" + | |
@@ -5991,6 +5994,12 @@ bool UnitTestImpl::RunAllTests() { | |||
| 5991 | 5994 | } | |
| 5992 | 5995 | ||
| 5993 | 5996 | repeater->OnTestProgramEnd(*parent_); | |
| 5997 | + // Destroy environments in normal code, not in static teardown. | ||
| 5998 | + bool delete_environment_on_teardown = true; | ||
| 5999 | + if (delete_environment_on_teardown) { | ||
| 6000 | + ForEach(environments_, internal::Delete<Environment>); | ||
| 6001 | + environments_.clear(); | ||
| 6002 | + } | ||
| 5994 | 6003 | ||
| 5995 | 6004 | if (!gtest_is_initialized_before_run_all_tests) { | |
| 5996 | 6005 | ColoredPrintf( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments