summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Derek Mauro <dmauro@google.com>2022-06-15 17:27:41 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-06-15 17:28:25 -0700
commit6b6d40f999f09b1bbc0150e8f57a2c39a93d25e5 (patch)
treed3e7e6537921db9a7b3f5e59fdc637b0c30a7d71 /absl
parent509f275822e8158bf76a9b24830a8de9d2fdfef2 (diff)
Update GoogleTest version used by Abseil
As part of this update, GoogleTest is now using the Abseil flags implementation, and the flags usage_test needs to be modified to pass. If building with bazel and --define=absl=1 to force GoogleTest to use Abseil, a WORKSPACE dependency on the abseil branch of the RE2 project is now required. PiperOrigin-RevId: 455257879 Change-Id: Id1548ce7d6a95b747b72a4f255d31ced98e36006
Diffstat (limited to 'absl')
-rw-r--r--absl/flags/CMakeLists.txt2
-rw-r--r--absl/flags/internal/usage_test.cc18
2 files changed, 14 insertions, 6 deletions
diff --git a/absl/flags/CMakeLists.txt b/absl/flags/CMakeLists.txt
index 79e51a11..3e9d5adf 100644
--- a/absl/flags/CMakeLists.txt
+++ b/absl/flags/CMakeLists.txt
@@ -466,5 +466,5 @@ absl_cc_test(
absl::flags_reflection
absl::flags_usage
absl::strings
- GTest::gtest
+ GTest::gmock
)
diff --git a/absl/flags/internal/usage_test.cc b/absl/flags/internal/usage_test.cc
index 6a65a1a3..209a7be9 100644
--- a/absl/flags/internal/usage_test.cc
+++ b/absl/flags/internal/usage_test.cc
@@ -20,6 +20,7 @@
#include <sstream>
#include <string>
+#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/flags/flag.h"
#include "absl/flags/internal/parse.h"
@@ -105,14 +106,19 @@ class UsageReportingTest : public testing::Test {
using UsageReportingDeathTest = UsageReportingTest;
TEST_F(UsageReportingDeathTest, TestSetProgramUsageMessage) {
+#if !defined(GTEST_HAS_ABSL) || !GTEST_HAS_ABSL
+ // Check for kTestUsageMessage set in main() below.
EXPECT_EQ(absl::ProgramUsageMessage(), kTestUsageMessage);
+#else
+ // Check for part of the usage message set by GoogleTest.
+ EXPECT_THAT(absl::ProgramUsageMessage(),
+ ::testing::HasSubstr(
+ "This program contains tests written using Google Test"));
+#endif
-#ifndef _WIN32
- // TODO(rogeeff): figure out why this does not work on Windows.
EXPECT_DEATH_IF_SUPPORTED(
absl::SetProgramUsageMessage("custom usage message"),
- ".*SetProgramUsageMessage\\(\\) called twice.*");
-#endif
+ ::testing::HasSubstr("SetProgramUsageMessage() called twice"));
}
// --------------------------------------------------------------------
@@ -489,8 +495,10 @@ path.
int main(int argc, char* argv[]) {
(void)absl::GetFlag(FLAGS_undefok); // Force linking of parse.cc
flags::SetProgramInvocationName("usage_test");
+#if !defined(GTEST_HAS_ABSL) || !GTEST_HAS_ABSL
+ // GoogleTest calls absl::SetProgramUsageMessage() already.
absl::SetProgramUsageMessage(kTestUsageMessage);
+#endif
::testing::InitGoogleTest(&argc, argv);
-
return RUN_ALL_TESTS();
}