naiveproxy/ui/file_manager/js_unit_tests.gni
2018-12-09 21:59:24 -05:00

69 lines
1.9 KiB
Plaintext

# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni")
# Describes a list of js_library targets that will each have an html file
# written listing all its (flattened) js dependencies, for loading as a test.
# Must be declared after the js_library targets it depends on.
#
# Variables:
# deps:
# List of js_library targets to depend on
#
# mocks:
# An optional list of .js files to load before any other scripts
#
# Example:
# js_unit_tests("folder_tests") {
# deps = [
# ":foo_unittest",
# ":bar_unittest",
# ":baz_unittest",
# ]
# mocks = [ "my_mocks.js" ]
# }
template("js_unit_tests") {
html_gen_target_name = target_name + "_html_gen"
action_foreach(html_gen_target_name) {
script_path = "//ui/file_manager"
script = "$script_path/js_unit_test.py"
forward_variables_from(invoker,
[
"deps",
"mocks",
])
sources = []
foreach(dep, deps) {
sources += get_target_outputs(dep)
}
outputs = [
"$target_gen_dir/{{source_name_part}}.html",
]
args = [ "--output" ] + rebase_path(outputs, root_build_dir)
args += [ "--input" ] + [ "{{source}}" ]
if (defined(mocks)) {
args += [ "--mocks" ] + rebase_path(mocks, root_build_dir)
data = mocks
}
}
type_check_deps = []
foreach(dep, invoker.deps) {
type_check_target_name = target_name + "_" + dep + "_type_check"
type_check_deps += [ ":$type_check_target_name" ]
js_type_check(type_check_target_name) {
deps = [
dep,
]
}
}
group(target_name) {
data = get_target_outputs(":$html_gen_target_name")
deps = [ ":$html_gen_target_name" ] + type_check_deps
}
}