diff -Naur googletest-5a509dbd2e5a6c694116e329c5a20dc190653724/BUILD.bazel googletest.new/BUILD.bazel --- BUILD.bazel +++ BUILD.bazel @@ -159,11 +159,14 @@ cc_library( name = "gtest_main", srcs = ["googlemock/src/gmock_main.cc"], features = select({ ":windows": ["windows_export_all_symbols"], "//conditions:default": [], }), - deps = [":gtest"], + deps = select({ + ":has_absl": ["@com_google_absl//absl/flags:parse"], + "//conditions:default": [], + }) + [":gtest"], ) # The following rules build samples of how to use gTest. diff -Naur googletest-5a509dbd2e5a6c694116e329c5a20dc190653724/googlemock/src/gmock_main.cc googletest.new/googlemock/src/gmock_main.cc --- googlemock/src/gmock_main.cc +++ googlemock/src/gmock_main.cc @@ -32,6 +32,9 @@ #include +#if GTEST_HAS_ABSL +#include "absl/flags/parse.h" +#endif // GTEST_HAS_ABSL #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -70,6 +73,9 @@ // also responsible for initializing Google Test. Therefore there's // no need for calling testing::InitGoogleTest() separately. testing::InitGoogleMock(&argc, argv); +#if GTEST_HAS_ABSL + absl::ParseCommandLine(argc, argv); +#endif // GTEST_HAS_ABSL return RUN_ALL_TESTS(); } #endif diff -Naur googletest-5a509dbd2e5a6c694116e329c5a20dc190653724/googletest/src/gtest_main.cc googletest.new/googletest/src/gtest_main.cc --- googletest/src/gtest_main.cc +++ googletest/src/gtest_main.cc @@ -50,6 +50,9 @@ GTEST_API_ int main(int argc, char **argv) { printf("Running main() from %s\n", __FILE__); testing::InitGoogleTest(&argc, argv); +#if GTEST_HAS_ABSL + absl::ParseCommandLine(argc, argv); +#endif // GTEST_HAS_ABSL return RUN_ALL_TESTS(); } #endif