Fix ordering of ParseCommandLineFlags() & InitGoogleTest() for Windows. - On Windows gtest passes additional non-gflags command line flags for death-tests, to avoid gflags invoking an error for these flags InitGoogleTest() must be called before ParseCommandLineFlags() to handle and remove them before gflags parses the remaining flags. Change-Id: I0c705ecd3aa029b70a2589b592e6a2c192745c0e
diff --git a/internal/ceres/gmock_main.cc b/internal/ceres/gmock_main.cc index 92b74d2..482d293 100644 --- a/internal/ceres/gmock_main.cc +++ b/internal/ceres/gmock_main.cc
@@ -52,11 +52,17 @@ #else int main(int argc, char** argv) { #endif // GTEST_OS_WINDOWS_MOBILE - google::ParseCommandLineFlags(&argc, &argv, true); google::InitGoogleLogging(argv[0]); // Since Google Mock depends on Google Test, InitGoogleMock() is // also responsible for initializing Google Test. Therefore there's // no need for calling testing::InitGoogleTest() separately. testing::InitGoogleMock(&argc, argv); + // On Windows, gtest passes additional non-gflags command line flags to + // death-tests, specifically --gtest_filter & --gtest_internal_run_death_test + // in order that these unknown (to gflags) flags do not invoke an error in + // gflags, InitGoogleTest() (called by InitGoogleMock()) must be called + // before ParseCommandLineFlags() to handle & remove them before gflags + // parses the remaining flags. + google::ParseCommandLineFlags(&argc, &argv, true); return RUN_ALL_TESTS(); }