tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

private_code_test.gni (3167B)


      1 # Copyright 2023 The Chromium Authors
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import("//testing/test.gni")
      6 
      7 template("private_code_test") {
      8   testonly = true
      9   assert(!is_component_build, "Guard your test behind if (!is_component_build)")
     10 
     11   _linker_inputs_dep = invoker.linker_inputs_dep
     12   _dir = get_label_info(_linker_inputs_dep, "root_out_dir")
     13 
     14   if (defined(invoker.executable_name)) {
     15     _executable_path = "$_dir/${invoker.executable_name}"
     16   } else {
     17     if (is_android) {
     18       _dir += "/lib.unstripped"
     19     }
     20     if (shlib_prefix != "") {
     21       _so_name = shlib_prefix + get_label_info(_linker_inputs_dep, "name")
     22       _so_name = string_replace(_so_name,
     23                                 "${shlib_prefix}${shlib_prefix}",
     24                                 shlib_prefix)
     25     }
     26     _executable_path = "$_dir/${_so_name}$shlib_extension"
     27   }
     28 
     29   _collect_sources_output = "$target_gen_dir/$target_name.json"
     30   _collect_sources_target_name = "${target_name}__parse_ninja"
     31   action(_collect_sources_target_name) {
     32     script = "//chromium/build/private_code_test/ninja_parser.py"
     33     outputs = [ _collect_sources_output ]
     34     inputs = [ "//chromium/build/action_helpers.py" ]
     35     depfile = "$target_gen_dir/$target_name.d"
     36 
     37     # The script does not read this file, so the dep is not really required.
     38     # It is needed only in the case where the target is in a different
     39     # toolchain, and would not be added to build.ninja otherwise.
     40     if (get_label_info(_linker_inputs_dep, "toolchain") != default_toolchain) {
     41       deps = [ _linker_inputs_dep ]
     42     }
     43     args = [
     44       "--executable",
     45       rebase_path(_executable_path, root_build_dir),
     46       "--result-json",
     47       rebase_path(_collect_sources_output, root_build_dir),
     48       "--depfile",
     49       rebase_path(depfile, root_build_dir),
     50     ]
     51   }
     52 
     53   isolated_script_test(target_name) {
     54     script = "//chromium/build/private_code_test/private_code_test.py"
     55     if (defined(invoker.private_paths_dep)) {
     56       _private_paths_dep = invoker.private_paths_dep
     57       _private_paths_file = invoker.private_paths_file
     58     } else {
     59       _private_paths_dep =
     60           "//chromium/build/private_code_test:private_paths($default_toolchain)"
     61       _private_paths_file =
     62           get_label_info(_private_paths_dep, "target_gen_dir") +
     63           "/private_paths.txt"
     64     }
     65 
     66     data_deps = [
     67       ":$_collect_sources_target_name",
     68       _private_paths_dep,
     69     ]
     70     args = [
     71       "--collect-sources-json",
     72       "@WrappedPath(" + rebase_path(_collect_sources_output, root_build_dir) +
     73           ")",
     74       "--private-paths-file",
     75       "@WrappedPath(" + rebase_path(_private_paths_file, root_build_dir) + ")",
     76       "--root-out-dir",
     77       rebase_path(get_label_info(_linker_inputs_dep, "root_out_dir"),
     78                   root_build_dir),
     79     ]
     80     if (defined(invoker.allowed_violations)) {
     81       foreach(_glob, invoker.allowed_violations) {
     82         args += [
     83           "--allow-violation",
     84           _glob,
     85         ]
     86       }
     87     }
     88     if (defined(invoker.expect_failure) && invoker.expect_failure) {
     89       args += [ "--expect-failure" ]
     90     }
     91   }
     92 }