| # Copyright 2026 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//third_party/node/node.gni") |
| |
| template("check_tests_referenced") { |
| node(target_name) { |
| script = "//chrome/test/data/webui/check_tests_referenced.py" |
| |
| forward_variables_from(invoker, |
| [ |
| "deps", |
| "in_folder", |
| "cc_files", |
| "ts_files", |
| "visibility", |
| ]) |
| |
| # Normalize cc_files paths before passing to the Python script to support a |
| # corner case where multiple *browsertest.cc files exist residing in |
| # different folders (some of them in a parent folder). |
| cc_files_normalized = [] |
| foreach(f, cc_files) { |
| extension = get_path_info(f, "extension") |
| if (!is_chromeos) { |
| assert(extension == "cc") |
| } else { |
| # On CrOS there are still old js2gtest tests so allow .js extension as |
| # well. |
| assert(extension == "cc" || extension == "js") |
| } |
| cc_files_normalized += [ rebase_path(f, root_build_dir) ] |
| } |
| |
| foreach(f, ts_files) { |
| extension = get_path_info(f, "extension") |
| assert(extension == "ts" || extension == "js") |
| } |
| inputs = cc_files + ts_files |
| |
| # Dummy file holding an 'OK' string if the target succeeds. This is |
| # necessary because GN requires all targets to have at least one output. |
| out_file = "${target_gen_dir}/${target_name}_result.txt" |
| outputs = [ out_file ] |
| |
| args = [ |
| "--in_folder", |
| rebase_path(in_folder, root_build_dir), |
| "--out_file", |
| rebase_path(out_file, root_build_dir), |
| "--cc_files", |
| ] + cc_files_normalized + [ "--ts_files" ] + ts_files |
| } |
| } |