Support testonly
for closure_compile targets in ui/file_manager.
`testonly` ensures that test-only utility files are not depended on by release files. It also helps when navigating deps in GN's tools. To cut down on boilerplate, introduce `js_unittest` that automatically adds testonly = true to js_library and is a better description of these targets. Leave "test_support" libraries using js_library + testonly. Bug: 879035 Cq-Include-Trybots: luci.chromium.try:closure_compilation Change-Id: I5463718ef3f13ead4fd1efae150ff1f7830e43ad Reviewed-on: https://chromium-review.googlesource.com/c/1275725 Commit-Queue: Trent Apted <tapted@chromium.org> Reviewed-by: Jochen Eisinger <jochen@chromium.org> Reviewed-by: calamity <calamity@chromium.org> Reviewed-by: Noel Gordon <noel@chromium.org> Cr-Commit-Position: refs/heads/master@{#600200}
This commit is contained in:
1
BUILD.gn
1
BUILD.gn
@ -1167,6 +1167,7 @@ template("assert_valid_out_dir") {
|
|||||||
|
|
||||||
if (closure_compile) {
|
if (closure_compile) {
|
||||||
group("webui_closure_compile") {
|
group("webui_closure_compile") {
|
||||||
|
testonly = true
|
||||||
data_deps = [
|
data_deps = [
|
||||||
"chrome/browser/resources:closure_compile",
|
"chrome/browser/resources:closure_compile",
|
||||||
"content/browser/resources:closure_compile",
|
"content/browser/resources:closure_compile",
|
||||||
|
17
third_party/closure_compiler/compile_js.gni
vendored
17
third_party/closure_compiler/compile_js.gni
vendored
@ -48,11 +48,12 @@ template("js_library") {
|
|||||||
script = "$script_path/js_library.py"
|
script = "$script_path/js_library.py"
|
||||||
forward_variables_from(invoker,
|
forward_variables_from(invoker,
|
||||||
[
|
[
|
||||||
"sources",
|
|
||||||
"deps",
|
"deps",
|
||||||
"externs_list",
|
"externs_list",
|
||||||
"extra_sources",
|
|
||||||
"extra_deps",
|
"extra_deps",
|
||||||
|
"extra_sources",
|
||||||
|
"sources",
|
||||||
|
"testonly",
|
||||||
"visibility",
|
"visibility",
|
||||||
])
|
])
|
||||||
output_file = "$target_gen_dir/$target_name.js_library"
|
output_file = "$target_gen_dir/$target_name.js_library"
|
||||||
@ -146,15 +147,16 @@ template("js_binary") {
|
|||||||
script = "$script_path/js_binary.py"
|
script = "$script_path/js_binary.py"
|
||||||
forward_variables_from(invoker,
|
forward_variables_from(invoker,
|
||||||
[
|
[
|
||||||
"sources",
|
|
||||||
"deps",
|
|
||||||
"outputs",
|
|
||||||
"bootstrap_file",
|
"bootstrap_file",
|
||||||
"config_files",
|
"checks_only",
|
||||||
"closure_flags",
|
"closure_flags",
|
||||||
|
"config_files",
|
||||||
|
"deps",
|
||||||
"externs_list",
|
"externs_list",
|
||||||
"extra_deps",
|
"extra_deps",
|
||||||
"checks_only",
|
"outputs",
|
||||||
|
"sources",
|
||||||
|
"testonly",
|
||||||
])
|
])
|
||||||
args = [
|
args = [
|
||||||
"--compiler",
|
"--compiler",
|
||||||
@ -237,6 +239,7 @@ template("js_type_check") {
|
|||||||
[
|
[
|
||||||
"deps",
|
"deps",
|
||||||
"closure_flags",
|
"closure_flags",
|
||||||
|
"testonly",
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
23
third_party/closure_compiler/js_unit_tests.gni
vendored
23
third_party/closure_compiler/js_unit_tests.gni
vendored
@ -50,6 +50,7 @@ template("js_unit_tests") {
|
|||||||
"deps",
|
"deps",
|
||||||
"mocks",
|
"mocks",
|
||||||
])
|
])
|
||||||
|
testonly = true
|
||||||
sources = []
|
sources = []
|
||||||
foreach(dep, deps) {
|
foreach(dep, deps) {
|
||||||
sources += get_target_outputs(dep)
|
sources += get_target_outputs(dep)
|
||||||
@ -79,6 +80,7 @@ template("js_unit_tests") {
|
|||||||
type_check_target_name = target_name + "_" + dep + "_type_check"
|
type_check_target_name = target_name + "_" + dep + "_type_check"
|
||||||
type_check_deps += [ ":$type_check_target_name" ]
|
type_check_deps += [ ":$type_check_target_name" ]
|
||||||
js_type_check(type_check_target_name) {
|
js_type_check(type_check_target_name) {
|
||||||
|
testonly = true
|
||||||
forward_variables_from(invoker, [ "closure_flags" ])
|
forward_variables_from(invoker, [ "closure_flags" ])
|
||||||
deps = [
|
deps = [
|
||||||
dep,
|
dep,
|
||||||
@ -87,12 +89,33 @@ template("js_unit_tests") {
|
|||||||
}
|
}
|
||||||
type_check_group_name = target_name + "_type_check"
|
type_check_group_name = target_name + "_type_check"
|
||||||
group(type_check_group_name) {
|
group(type_check_group_name) {
|
||||||
|
testonly = true
|
||||||
deps = type_check_deps
|
deps = type_check_deps
|
||||||
}
|
}
|
||||||
group(target_name) {
|
group(target_name) {
|
||||||
data = get_target_outputs(":$html_gen_target_name")
|
data = get_target_outputs(":$html_gen_target_name")
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
":$html_gen_target_name",
|
":$html_gen_target_name",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Simple wrapper around js_library to describe a unit test.
|
||||||
|
template("js_unittest") {
|
||||||
|
js_library(target_name) {
|
||||||
|
testonly = true
|
||||||
|
|
||||||
|
# Forward everything that js_library forwards except testonly (omitting that
|
||||||
|
# causes gn to emit "Assignment had no effect" if it's added redundantly).
|
||||||
|
forward_variables_from(invoker,
|
||||||
|
[
|
||||||
|
"deps",
|
||||||
|
"externs_list",
|
||||||
|
"extra_deps",
|
||||||
|
"extra_sources",
|
||||||
|
"sources",
|
||||||
|
"visibility",
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -30,6 +30,10 @@ component("file_manager") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group("closure_compile") {
|
group("closure_compile") {
|
||||||
|
# Subfolders' closure_compile groups bundle the non-test "module" type-check
|
||||||
|
# groups as well as unittests and test_support.
|
||||||
|
testonly = true
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
"audio_player/elements:closure_compile",
|
"audio_player/elements:closure_compile",
|
||||||
"audio_player/js:closure_compile",
|
"audio_player/js:closure_compile",
|
||||||
@ -50,6 +54,7 @@ group("closure_compile") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group("unit_test_data") {
|
group("unit_test_data") {
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
"file_manager/background/js:unit_tests",
|
"file_manager/background/js:unit_tests",
|
||||||
"file_manager/common/js:unit_tests",
|
"file_manager/common/js:unit_tests",
|
||||||
|
@ -7,6 +7,7 @@ import("//third_party/closure_compiler/compile_js.gni")
|
|||||||
visibility = [ "//ui/file_manager/*" ]
|
visibility = [ "//ui/file_manager/*" ]
|
||||||
|
|
||||||
group("closure_compile") {
|
group("closure_compile") {
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
":closure_compile_module",
|
":closure_compile_module",
|
||||||
":test_support_type_check",
|
":test_support_type_check",
|
||||||
@ -21,6 +22,7 @@ js_type_check("closure_compile_module") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
js_type_check("test_support_type_check") {
|
js_type_check("test_support_type_check") {
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
":mock_chrome",
|
":mock_chrome",
|
||||||
":test_error_reporting",
|
":test_error_reporting",
|
||||||
@ -45,9 +47,11 @@ js_library("filtered_volume_manager") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
js_library("mock_chrome") {
|
js_library("mock_chrome") {
|
||||||
|
testonly = true
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("test_error_reporting") {
|
js_library("test_error_reporting") {
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
# Note we allow targets depending on test_error_reporting to access
|
# Note we allow targets depending on test_error_reporting to access
|
||||||
# webui_resource_test transitively.
|
# webui_resource_test transitively.
|
||||||
|
@ -19,6 +19,7 @@ related_apps = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
group("closure_compile") {
|
group("closure_compile") {
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
":closure_compile_module",
|
":closure_compile_module",
|
||||||
":unit_tests_type_check",
|
":unit_tests_type_check",
|
||||||
@ -305,7 +306,7 @@ js_library("volume_manager_factory") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("volume_manager_unittest") {
|
js_unittest("volume_manager_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":volume_manager_factory",
|
":volume_manager_factory",
|
||||||
"//ui/file_manager/base/js:mock_chrome",
|
"//ui/file_manager/base/js:mock_chrome",
|
||||||
|
@ -9,6 +9,7 @@ import("//third_party/closure_compiler/js_unit_tests.gni")
|
|||||||
visibility = [ "//ui/file_manager/*" ]
|
visibility = [ "//ui/file_manager/*" ]
|
||||||
|
|
||||||
group("closure_compile") {
|
group("closure_compile") {
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
":closure_compile_module",
|
":closure_compile_module",
|
||||||
":test_support_type_check",
|
":test_support_type_check",
|
||||||
@ -34,6 +35,7 @@ js_type_check("closure_compile_module") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
js_type_check("test_support_type_check") {
|
js_type_check("test_support_type_check") {
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
":test_importer_common",
|
":test_importer_common",
|
||||||
":unittest_util",
|
":unittest_util",
|
||||||
@ -43,7 +45,7 @@ js_type_check("test_support_type_check") {
|
|||||||
js_library("async_util") {
|
js_library("async_util") {
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("async_util_unittest") {
|
js_unittest("async_util_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":async_util",
|
":async_util",
|
||||||
"//ui/file_manager/base/js:test_error_reporting",
|
"//ui/file_manager/base/js:test_error_reporting",
|
||||||
@ -57,7 +59,7 @@ js_library("files_app_entry_types") {
|
|||||||
externs_list = [ "../../../externs/volume_info.js" ]
|
externs_list = [ "../../../externs/volume_info.js" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("files_app_entry_types_unittest") {
|
js_unittest("files_app_entry_types_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":files_app_entry_types",
|
":files_app_entry_types",
|
||||||
":volume_manager_common",
|
":volume_manager_common",
|
||||||
@ -91,6 +93,7 @@ js_library("importer_common") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
js_library("test_importer_common") {
|
js_library("test_importer_common") {
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
":importer_common",
|
":importer_common",
|
||||||
":unittest_util",
|
":unittest_util",
|
||||||
@ -100,7 +103,7 @@ js_library("test_importer_common") {
|
|||||||
visibility = [ "//ui/file_manager/file_manager/*" ]
|
visibility = [ "//ui/file_manager/file_manager/*" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("importer_common_unittest") {
|
js_unittest("importer_common_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":mock_entry",
|
":mock_entry",
|
||||||
":test_importer_common",
|
":test_importer_common",
|
||||||
@ -113,7 +116,7 @@ js_library("importer_common_unittest") {
|
|||||||
js_library("lru_cache") {
|
js_library("lru_cache") {
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("lru_cache_unittest") {
|
js_unittest("lru_cache_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":lru_cache",
|
":lru_cache",
|
||||||
"//ui/webui/resources/js:webui_resource_test",
|
"//ui/webui/resources/js:webui_resource_test",
|
||||||
@ -151,7 +154,7 @@ js_library("mock_entry") {
|
|||||||
js_library("progress_center_common") {
|
js_library("progress_center_common") {
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("unittest_util") {
|
js_unittest("unittest_util") {
|
||||||
# Only files app tests use this util file.
|
# Only files app tests use this util file.
|
||||||
visibility = []
|
visibility = []
|
||||||
visibility = [ "//ui/file_manager/file_manager/*" ]
|
visibility = [ "//ui/file_manager/file_manager/*" ]
|
||||||
@ -179,7 +182,7 @@ js_library("util") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("util_unittest") {
|
js_unittest("util_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":mock_entry",
|
":mock_entry",
|
||||||
":util",
|
":util",
|
||||||
|
@ -576,7 +576,7 @@ js_library("thumbnail_loader") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("thumbnail_loader_unittest") {
|
js_unittest("thumbnail_loader_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":thumbnail_loader",
|
":thumbnail_loader",
|
||||||
"../../common/js:mock_entry",
|
"../../common/js:mock_entry",
|
||||||
@ -614,6 +614,7 @@ js_unit_tests("unit_tests") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group("closure_compile") {
|
group("closure_compile") {
|
||||||
|
testonly = true
|
||||||
visibility += [ "*" ]
|
visibility += [ "*" ]
|
||||||
deps = [
|
deps = [
|
||||||
":closure_compile_module",
|
":closure_compile_module",
|
||||||
|
@ -43,7 +43,7 @@ js_library("dimmable_ui_controller") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("dimmable_ui_controller_unittest") {
|
js_unittest("dimmable_ui_controller_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":dimmable_ui_controller",
|
":dimmable_ui_controller",
|
||||||
"//ui/webui/resources/js:webui_resource_test",
|
"//ui/webui/resources/js:webui_resource_test",
|
||||||
@ -58,7 +58,7 @@ js_library("entry_list_watcher") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("entry_list_watcher_unittest") {
|
js_unittest("entry_list_watcher_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":entry_list_watcher",
|
":entry_list_watcher",
|
||||||
"../../file_manager/common/js:mock_entry",
|
"../../file_manager/common/js:mock_entry",
|
||||||
@ -99,7 +99,7 @@ js_library("gallery_data_model") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("gallery_data_model_unittest") {
|
js_unittest("gallery_data_model_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":gallery_data_model",
|
":gallery_data_model",
|
||||||
":mock_gallery_item",
|
":mock_gallery_item",
|
||||||
@ -120,7 +120,7 @@ js_library("gallery_item") {
|
|||||||
externs_list = [ "../../externs/entry_location.js" ]
|
externs_list = [ "../../externs/entry_location.js" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("gallery_item_unittest") {
|
js_unittest("gallery_item_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":gallery_item",
|
":gallery_item",
|
||||||
":mock_gallery_item",
|
":mock_gallery_item",
|
||||||
@ -137,7 +137,7 @@ js_library("gallery_util") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("gallery_util_unittest") {
|
js_unittest("gallery_util_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":gallery_util",
|
":gallery_util",
|
||||||
"../../file_manager/common/js:mock_entry",
|
"../../file_manager/common/js:mock_entry",
|
||||||
@ -168,7 +168,7 @@ js_library("ribbon") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("ribbon_unittest") {
|
js_unittest("ribbon_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":ribbon",
|
":ribbon",
|
||||||
]
|
]
|
||||||
@ -196,7 +196,7 @@ js_library("slide_mode") {
|
|||||||
externs_list = [ "../../externs/gallery_foreground.js" ]
|
externs_list = [ "../../externs/gallery_foreground.js" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("slide_mode_unittest") {
|
js_unittest("slide_mode_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":slide_mode",
|
":slide_mode",
|
||||||
"//ui/file_manager/base/js:test_error_reporting",
|
"//ui/file_manager/base/js:test_error_reporting",
|
||||||
@ -229,6 +229,7 @@ js_unit_tests("unit_tests") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group("closure_compile") {
|
group("closure_compile") {
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
":closure_compile_module",
|
":closure_compile_module",
|
||||||
":unit_tests_type_check",
|
":unit_tests_type_check",
|
||||||
|
@ -47,7 +47,7 @@ js_library("exif_encoder") {
|
|||||||
externs_list = [ "../../../externs/exif_entry.js" ]
|
externs_list = [ "../../../externs/exif_entry.js" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("exif_encoder_unittest") {
|
js_unittest("exif_encoder_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":exif_encoder",
|
":exif_encoder",
|
||||||
":test_util",
|
":test_util",
|
||||||
@ -120,7 +120,7 @@ js_library("image_encoder") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("image_encoder_unittest") {
|
js_unittest("image_encoder_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":image_encoder",
|
":image_encoder",
|
||||||
":test_util",
|
":test_util",
|
||||||
@ -179,7 +179,7 @@ js_library("image_view") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("image_view_unittest") {
|
js_unittest("image_view_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":image_view",
|
":image_view",
|
||||||
"..:mock_gallery_item",
|
"..:mock_gallery_item",
|
||||||
@ -207,6 +207,7 @@ js_unit_tests("unit_tests") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group("closure_compile") {
|
group("closure_compile") {
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
":closure_compile_module",
|
":closure_compile_module",
|
||||||
":unit_tests_type_check",
|
":unit_tests_type_check",
|
||||||
|
@ -29,7 +29,7 @@ js_library("background") {
|
|||||||
js_library("cache") {
|
js_library("cache") {
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("cache_unittest") {
|
js_unittest("cache_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":cache",
|
":cache",
|
||||||
":load_image_request",
|
":load_image_request",
|
||||||
@ -48,7 +48,7 @@ js_library("image_loader") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("image_loader_unittest") {
|
js_unittest("image_loader_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":image_loader",
|
":image_loader",
|
||||||
"//ui/webui/resources/js:webui_resource_test",
|
"//ui/webui/resources/js:webui_resource_test",
|
||||||
@ -82,7 +82,7 @@ js_library("image_loader_client") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("image_loader_client_unittest") {
|
js_unittest("image_loader_client_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":image_loader_client",
|
":image_loader_client",
|
||||||
"//ui/file_manager/base/js:test_error_reporting",
|
"//ui/file_manager/base/js:test_error_reporting",
|
||||||
@ -96,7 +96,7 @@ js_library("piex_loader") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
js_library("piex_loader_unittest") {
|
js_unittest("piex_loader_unittest") {
|
||||||
deps = [
|
deps = [
|
||||||
":piex_loader",
|
":piex_loader",
|
||||||
"//ui/file_manager/base/js:test_error_reporting",
|
"//ui/file_manager/base/js:test_error_reporting",
|
||||||
@ -133,6 +133,7 @@ js_unit_tests("unit_tests") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group("closure_compile") {
|
group("closure_compile") {
|
||||||
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
":closure_compile_module",
|
":closure_compile_module",
|
||||||
":unit_tests_type_check",
|
":unit_tests_type_check",
|
||||||
|
Reference in New Issue
Block a user