| # Copyright 2023 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//testing/test.gni") |
| |
| _default_allowed_violations = [ |
| # Public-branding counterpart defines the same resources. |
| "../../chrome/app/theme/google_chrome/*", |
| |
| # Defines public counterpart with same entries. |
| "../../components/metrics/internal/server_urls.grd", |
| |
| # TODO(b/452971335): Audit entries below. |
| "../../chrome/browser/internal/resources/additional_modules_list.input", |
| "../../chrome/browser/internal/transform_additional_modules_list.py", |
| "../../components/autofill/core/browser/form_parsing/internal_resources/0_default_regex_patterns.json", |
| "../../components/plus_addresses/core/browser/resources/internal/*", |
| "../../components/vector_icons/google_chrome/*", |
| "../../google_apis/internal/generate_metrics_key.py", |
| "../../third_party/search_engines_data/resources_internal/search_engines_scaled_resources.grd", |
| ] |
| |
| if (!is_android) { |
| _default_allowed_violations += [ |
| "../../chrome/browser/actor/resources/internal/browser_resources.grd", |
| "../../chrome/browser/glic/resources/internal/browser_resources.grd", |
| "../../chrome/browser/nearby_sharing/internal/nearby_share_internal_icons.grd", |
| "../../chrome/browser/nearby_sharing/internal/nearby_share_internal_strings.grd", |
| "../../chrome/browser/resources/downloads/internal/icons.html", |
| "../../chrome/browser/resources/settings/internal/icons.html", |
| "../../third_party/search_engines_data/resources_internal/search_engine_descriptions_strings.grd", |
| "../../third_party/widevine/cdm/linux/x64/manifest.json", |
| ] |
| } |
| |
| template("private_code_test") { |
| testonly = true |
| assert(!is_component_build, "Guard your test behind if (!is_component_build)") |
| |
| _linker_inputs_dep = invoker.linker_inputs_dep |
| _dir = get_label_info(_linker_inputs_dep, "root_out_dir") |
| |
| if (defined(invoker.executable_name)) { |
| _executable_path = "$_dir/${invoker.executable_name}" |
| } else { |
| if (is_android) { |
| _dir += "/lib.unstripped" |
| } |
| if (shlib_prefix != "") { |
| _so_name = shlib_prefix + get_label_info(_linker_inputs_dep, "name") |
| _so_name = string_replace(_so_name, |
| "${shlib_prefix}${shlib_prefix}", |
| shlib_prefix) |
| } |
| _executable_path = "$_dir/${_so_name}$shlib_extension" |
| } |
| |
| _collect_sources_output = "$target_gen_dir/$target_name.json" |
| _collect_sources_target_name = "${target_name}__parse_ninja" |
| action(_collect_sources_target_name) { |
| script = "//build/private_code_test/ninja_parser.py" |
| outputs = [ _collect_sources_output ] |
| inputs = [ "//build/action_helpers.py" ] |
| depfile = "$target_gen_dir/$target_name.d" |
| |
| # The script does not read this file, so the dep is not really required. |
| # It is needed only in the case where the target is in a different |
| # toolchain, and would not be added to build.ninja otherwise. |
| if (get_label_info(_linker_inputs_dep, "toolchain") != default_toolchain) { |
| deps = [ _linker_inputs_dep ] |
| } |
| args = [ |
| "--executable", |
| rebase_path(_executable_path, root_build_dir), |
| "--result-json", |
| rebase_path(_collect_sources_output, root_build_dir), |
| "--depfile", |
| rebase_path(depfile, root_build_dir), |
| ] |
| } |
| |
| isolated_script_test(target_name) { |
| script = "//build/private_code_test/private_code_test.py" |
| if (defined(invoker.private_paths_dep)) { |
| _private_paths_dep = invoker.private_paths_dep |
| _private_paths_file = invoker.private_paths_file |
| } else { |
| _private_paths_dep = |
| "//build/private_code_test:private_paths($default_toolchain)" |
| _private_paths_file = |
| get_label_info(_private_paths_dep, "target_gen_dir") + |
| "/private_paths.txt" |
| } |
| |
| data_deps = [ |
| ":$_collect_sources_target_name", |
| _private_paths_dep, |
| ] |
| args = [ |
| "--collect-sources-json", |
| "@WrappedPath(" + rebase_path(_collect_sources_output, root_build_dir) + |
| ")", |
| "--private-paths-file", |
| "@WrappedPath(" + rebase_path(_private_paths_file, root_build_dir) + ")", |
| "--root-out-dir", |
| rebase_path(get_label_info(_linker_inputs_dep, "root_out_dir"), |
| root_build_dir), |
| ] |
| _globs = _default_allowed_violations |
| if (defined(invoker.allowed_violations)) { |
| _globs += invoker.allowed_violations |
| } |
| foreach(_glob, _globs) { |
| args += [ |
| "--allow-violation", |
| _glob, |
| ] |
| } |
| if (defined(invoker.expect_failure) && invoker.expect_failure) { |
| args += [ "--expect-failure" ] |
| } |
| } |
| } |