diff --git a/test/BUILD.gn b/test/BUILD.gn index 1cad688951..f544353110 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -422,7 +422,6 @@ if (rtc_include_tests) { ] absl_deps = [ "//third_party/abseil-cpp/absl/flags:flag", - "//third_party/abseil-cpp/absl/flags:parse", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:strings", "//third_party/abseil-cpp/absl/types:optional", @@ -434,10 +433,15 @@ if (rtc_include_tests) { testonly = true sources = [ "test_main.cc" ] - deps = [ ":test_main_lib" ] + deps = [ + ":test_main_lib", + ":test_support", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/debugging:failure_signal_handler", "//third_party/abseil-cpp/absl/debugging:symbolize", + "//third_party/abseil-cpp/absl/flags:parse", ] } diff --git a/test/test_main.cc b/test/test_main.cc index 5046979548..f919c4bba7 100644 --- a/test/test_main.cc +++ b/test/test_main.cc @@ -12,17 +12,21 @@ #include "absl/debugging/failure_signal_handler.h" #include "absl/debugging/symbolize.h" +#include "absl/flags/parse.h" +#include "test/gmock.h" #include "test/test_main_lib.h" int main(int argc, char* argv[]) { // Initialize the symbolizer to get a human-readable stack trace absl::InitializeSymbolizer(argv[0]); + testing::InitGoogleMock(&argc, argv); + absl::ParseCommandLine(argc, argv); absl::FailureSignalHandlerOptions options; absl::InstallFailureSignalHandler(options); std::unique_ptr main = webrtc::TestMain::Create(); - int err_code = main->Init(&argc, argv); + int err_code = main->Init(); if (err_code != 0) { return err_code; } diff --git a/test/test_main_lib.cc b/test/test_main_lib.cc index f5e02341f3..7170163346 100644 --- a/test/test_main_lib.cc +++ b/test/test_main_lib.cc @@ -15,7 +15,6 @@ #include #include "absl/flags/flag.h" -#include "absl/flags/parse.h" #include "absl/memory/memory.h" #include "absl/strings/match.h" #include "absl/types/optional.h" @@ -28,7 +27,6 @@ #include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/metrics.h" #include "test/field_trial.h" -#include "test/gmock.h" #include "test/gtest.h" #include "test/testsupport/perf_test.h" #include "test/testsupport/resources_dir_flag.h" @@ -157,10 +155,9 @@ class TestMainImpl : public TestMain { std::unique_ptr thread_; }; - int Init(int* argc, char* argv[]) override { - ::testing::InitGoogleMock(argc, argv); - absl::ParseCommandLine(*argc, argv); + int Init(int* argc, char* argv[]) override { return Init(); } + int Init() override { // Make sure we always pull in the --resources_dir flag, even if the test // binary doesn't link with fileutils (downstream expects all test mains to // have this flag). diff --git a/test/test_main_lib.h b/test/test_main_lib.h index bdb0afb6eb..2233171c60 100644 --- a/test/test_main_lib.h +++ b/test/test_main_lib.h @@ -25,6 +25,8 @@ class TestMain { // Initializes test environment. Clients can add their own initialization // steps after call to this method and before running tests. // Returns 0 if initialization was successful and non 0 otherwise. + virtual int Init() = 0; + // Temporary for backward compatibility virtual int Init(int* argc, char* argv[]) = 0; // Runs test end return result error code. 0 - no errors.