If GTEST_NO_ABSL_FLAGS is #defined, then the Abseil flag library
will not be used by googletest, even if GTEST_HAS_ABSL is #defined. PiperOrigin-RevId: 599625032 Change-Id: Ieb994a15683dec89e88578120071eca8ac9fead1
This commit is contained in:
parent
f6f920d2ba
commit
96cd50c082
@ -338,9 +338,10 @@
|
||||
#define GTEST_HAS_NOTIFICATION_ 0
|
||||
#endif
|
||||
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
#include "absl/flags/declare.h"
|
||||
#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
|
||||
#define GTEST_INTERNAL_HAS_ABSL_FLAGS // Used only in this file.
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/declare.h"
|
||||
#include "absl/flags/reflection.h"
|
||||
#endif
|
||||
|
||||
@ -2252,7 +2253,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
|
||||
#endif // !defined(GTEST_FLAG)
|
||||
|
||||
// Pick a command line flags implementation.
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
#ifdef GTEST_INTERNAL_HAS_ABSL_FLAGS
|
||||
|
||||
// Macros for defining flags.
|
||||
#define GTEST_DEFINE_bool_(name, default_val, doc) \
|
||||
@ -2277,7 +2278,8 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
|
||||
(void)(::absl::SetFlag(>EST_FLAG(name), value))
|
||||
#define GTEST_USE_OWN_FLAGFILE_FLAG_ 0
|
||||
|
||||
#else // GTEST_HAS_ABSL
|
||||
#undef GTEST_INTERNAL_HAS_ABSL_FLAGS
|
||||
#else // ndef GTEST_INTERNAL_HAS_ABSL_FLAGS
|
||||
|
||||
// Macros for defining flags.
|
||||
#define GTEST_DEFINE_bool_(name, default_val, doc) \
|
||||
@ -2319,7 +2321,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
|
||||
#define GTEST_FLAG_SET(name, value) (void)(::testing::GTEST_FLAG(name) = value)
|
||||
#define GTEST_USE_OWN_FLAGFILE_FLAG_ 1
|
||||
|
||||
#endif // GTEST_HAS_ABSL
|
||||
#endif // GTEST_INTERNAL_HAS_ABSL_FLAGS
|
||||
|
||||
// Thread annotations
|
||||
#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
|
||||
|
@ -162,6 +162,10 @@
|
||||
#define GTEST_HAS_BUILTIN(x) 0
|
||||
#endif // defined(__has_builtin)
|
||||
|
||||
#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
|
||||
#define GTEST_HAS_ABSL_FLAGS
|
||||
#endif
|
||||
|
||||
namespace testing {
|
||||
|
||||
using internal::CountIf;
|
||||
@ -6688,7 +6692,7 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
|
||||
// remain in place. Unrecognized flags are not reported and do not cause the
|
||||
// program to exit.
|
||||
void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
#ifdef GTEST_HAS_ABSL_FLAGS
|
||||
if (*argc <= 0) return;
|
||||
|
||||
std::vector<char*> positional_args;
|
||||
@ -6774,11 +6778,13 @@ void InitGoogleTestImpl(int* argc, CharType** argv) {
|
||||
#ifdef GTEST_HAS_ABSL
|
||||
absl::InitializeSymbolizer(g_argvs[0].c_str());
|
||||
|
||||
#ifdef GTEST_HAS_ABSL_FLAGS
|
||||
// When using the Abseil Flags library, set the program usage message to the
|
||||
// help message, but remove the color-encoding from the message first.
|
||||
absl::SetProgramUsageMessage(absl::StrReplaceAll(
|
||||
kColorEncodedHelpMessage,
|
||||
{{"@D", ""}, {"@R", ""}, {"@G", ""}, {"@Y", ""}, {"@@", "@"}}));
|
||||
#endif // GTEST_HAS_ABSL_FLAGS
|
||||
#endif // GTEST_HAS_ABSL
|
||||
|
||||
ParseGoogleTestFlagsOnly(argc, argv);
|
||||
|
Loading…
Reference in New Issue
Block a user