mirror of
https://github.com/google/googletest.git
synced 2026-02-07 02:09:53 +08:00
Separate the creation of the Premature Exit File from supporting Death Tests.
The [Premature Exit File](https://google.github.io/googletest/advanced.html#detecting-test-premature-exit) can be used for more than just death tests. Runners can use it to detect any kind of unexpected exit. Presently, its creation is tied to whether a platform supports Death Tests. This change removes that coupling (though if Death Tests are supported, then the Premature Exit file is implicitly supported). PiperOrigin-RevId: 853416224 Change-Id: I5354730b82bc8a20981120f4e1df59b58cb31f6e
This commit is contained in:
parent
7d7e750850
commit
5554fcaab4
@ -119,6 +119,8 @@
|
||||
#define GTEST_OS_NXP_QN9090 1
|
||||
#elif defined(NRF52)
|
||||
#define GTEST_OS_NRF52 1
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#define GTEST_OS_EMSCRIPTEN 1
|
||||
#endif // __CYGWIN__
|
||||
|
||||
#endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
|
||||
|
||||
@ -664,12 +664,22 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
|
||||
defined(GTEST_OS_NETBSD) || defined(GTEST_OS_FUCHSIA) || \
|
||||
defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_GNU_KFREEBSD) || \
|
||||
defined(GTEST_OS_HAIKU) || defined(GTEST_OS_GNU_HURD))
|
||||
|
||||
// Death tests require a file system to work properly.
|
||||
#if GTEST_HAS_FILE_SYSTEM
|
||||
#define GTEST_HAS_DEATH_TEST 1
|
||||
#endif // GTEST_HAS_FILE_SYSTEM
|
||||
#endif
|
||||
|
||||
// Determines whether the Premature Exit file can be created.
|
||||
// Created by default when Death tests are supported, but other platforms can
|
||||
// use the Premature exit file without Death test support (e.g. for detecting
|
||||
// crashes).
|
||||
#if GTEST_HAS_DEATH_TEST || \
|
||||
(defined(GTEST_OS_EMSCRIPTEN) && GTEST_HAS_FILE_SYSTEM)
|
||||
#define GTEST_INTERNAL_HAS_PREMATURE_EXIT_FILE 1
|
||||
#endif
|
||||
|
||||
// Determines whether to support type-driven tests.
|
||||
|
||||
// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
|
||||
|
||||
@ -5132,7 +5132,7 @@ void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) {
|
||||
#endif // GTEST_HAS_ABSL
|
||||
}
|
||||
|
||||
#ifdef GTEST_HAS_DEATH_TEST
|
||||
#ifdef GTEST_INTERNAL_HAS_PREMATURE_EXIT_FILE
|
||||
// A helper class that creates the premature-exit file in its
|
||||
// constructor and deletes the file in its destructor.
|
||||
class ScopedPrematureExitFile {
|
||||
@ -5170,7 +5170,7 @@ class ScopedPrematureExitFile {
|
||||
ScopedPrematureExitFile(const ScopedPrematureExitFile&) = delete;
|
||||
ScopedPrematureExitFile& operator=(const ScopedPrematureExitFile&) = delete;
|
||||
};
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
#endif // GTEST_INTERNAL_HAS_PREMATURE_EXIT_FILE
|
||||
|
||||
} // namespace internal
|
||||
|
||||
@ -5515,7 +5515,7 @@ void UnitTest::RecordProperty(const std::string& key,
|
||||
// We don't protect this under mutex_, as we only support calling it
|
||||
// from the main thread.
|
||||
int UnitTest::Run() {
|
||||
#ifdef GTEST_HAS_DEATH_TEST
|
||||
#ifdef GTEST_INTERNAL_HAS_PREMATURE_EXIT_FILE
|
||||
const bool in_death_test_child_process =
|
||||
!GTEST_FLAG_GET(internal_run_death_test).empty();
|
||||
|
||||
@ -5546,7 +5546,7 @@ int UnitTest::Run() {
|
||||
: internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE"));
|
||||
#else
|
||||
const bool in_death_test_child_process = false;
|
||||
#endif // GTEST_HAS_DEATH_TEST
|
||||
#endif // GTEST_INTERNAL_HAS_PREMATURE_EXIT_FILE
|
||||
|
||||
// Captures the value of GTEST_FLAG(catch_exceptions). This value will be
|
||||
// used for the duration of the program.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user