From 844600e8a4e26013891aa5d53c6531305d068ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20H=C3=B6glund?= Date: Tue, 15 Oct 2019 12:19:36 +0200 Subject: [PATCH] Put the resources_dir flag into its own target. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I had to change approach. Unfortunately we can't expect that test_main_lib users link with fileutils, which causes it to not link when the override symbol is missing. New approach: resources_dir_flag is now a separate target, it will be depended upon by the downstream override, which just reads the flag and returns it as the resource dir. This gets rid of the mutable state downstream as well. So: 1) Land this 2) Make downstream read the flag instead of keeping its own state 3) Remove OverrideResourcesDir upstream and clean up the hacks 4) Remove the now orphaned OverrideResourcesDir downstream Bug: webrtc:9792 Change-Id: Ic2ef3910bb5d39d9fb71e06fbbbb6aec4de52e78 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157041 Commit-Queue: Patrik Höglund Reviewed-by: Mirko Bonadei Cr-Commit-Position: refs/heads/master@{#29487} --- test/BUILD.gn | 13 +++++++++++++ test/test_main_lib.cc | 9 +-------- test/testsupport/resources_dir_flag.cc | 19 +++++++++++++++++++ test/testsupport/resources_dir_flag.h | 20 ++++++++++++++++++++ 4 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 test/testsupport/resources_dir_flag.cc create mode 100644 test/testsupport/resources_dir_flag.h diff --git a/test/BUILD.gn b/test/BUILD.gn index 00b78d43e7..96321ee2d9 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -255,6 +255,7 @@ if (rtc_include_tests) { ":field_trial", ":fileutils_override_api", ":perf_test", + ":resources_dir_flag", ":test_support", "../rtc_base", "../rtc_base:checks", @@ -500,6 +501,18 @@ rtc_source_set("fileutils") { } } +rtc_source_set("resources_dir_flag") { + testonly = true + visibility = [ "*" ] + sources = [ + "testsupport/resources_dir_flag.cc", + "testsupport/resources_dir_flag.h", + ] + deps = [ + "//third_party/abseil-cpp/absl/flags:flag", + ] +} + # We separate header into own target to make it possible for downstream # projects to override implementation. rtc_source_set("fileutils_override_api") { diff --git a/test/test_main_lib.cc b/test/test_main_lib.cc index 1650d2ac79..178eda7c75 100644 --- a/test/test_main_lib.cc +++ b/test/test_main_lib.cc @@ -30,6 +30,7 @@ #include "test/testsupport/file_utils.h" #include "test/testsupport/file_utils_override.h" #include "test/testsupport/perf_test.h" +#include "test/testsupport/resources_dir_flag.h" #if defined(WEBRTC_WIN) #include "rtc_base/win32_socket_init.h" @@ -81,14 +82,6 @@ ABSL_FLAG(std::vector, #endif -ABSL_FLAG(std::string, - resources_dir, - "", - "Where to look for the runtime dependencies. If not specified, we " - "will use a reasonable default depending on where we are running. " - "This flag is useful if we copy over test resources to a phone and " - "need to tell the tests where their resources are."); - ABSL_FLAG(bool, logs, true, "print logs to stderr"); ABSL_FLAG(bool, verbose, false, "verbose logs to stderr"); diff --git a/test/testsupport/resources_dir_flag.cc b/test/testsupport/resources_dir_flag.cc new file mode 100644 index 0000000000..a6ab3b537b --- /dev/null +++ b/test/testsupport/resources_dir_flag.cc @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "test/testsupport/resources_dir_flag.h" + +ABSL_FLAG(std::string, + resources_dir, + "", + "Where to look for the runtime dependencies. If not specified, we " + "will use a reasonable default depending on where we are running. " + "This flag is useful if we copy over test resources to a phone and " + "need to tell the tests where their resources are."); diff --git a/test/testsupport/resources_dir_flag.h b/test/testsupport/resources_dir_flag.h new file mode 100644 index 0000000000..055cc82546 --- /dev/null +++ b/test/testsupport/resources_dir_flag.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include + +#ifndef TEST_TESTSUPPORT_RESOURCES_DIR_FLAG_H__ +#define TEST_TESTSUPPORT_RESOURCES_DIR_FLAG_H__ + +#include "absl/flags/flag.h" + +ABSL_DECLARE_FLAG(std::string, resources_dir); + +#endif // TEST_TESTSUPPORT_RESOURCES_DIR_FLAG_H__