| # Copyright 2018 The Fuchsia 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("//build/testing/test_spec.gni") |
| |
| # This declares a test executable. |
| # |
| # The parameters are precisely those of an `executable`, along with |
| # |
| # environments |
| # Optional: What environments this test should target. Only used here for |
| # linux and mac tests, with a default value of a general linux/mac |
| # environment (as a function of $current_os). |
| # See //build/testing/test_spec.gni for more details. |
| # |
| template("test") { |
| if (is_linux || is_mac) { |
| test_spec("${target_name}_spec") { |
| testonly = true |
| name = invoker.target_name |
| location = "$root_out_dir/${invoker.target_name}" |
| deps = [] |
| if (defined(invoker.deps)) { |
| deps += invoker.deps |
| } |
| if (defined(invoker.data_deps)) { |
| deps += invoker.data_deps |
| } |
| forward_variables_from(invoker, [ "environments" ]) |
| } |
| } else { |
| if (defined(invoker.environments)) { |
| not_needed(invoker, [ "environments" ]) |
| } |
| } |
| |
| executable(target_name) { |
| forward_variables_from(invoker, "*") |
| testonly = true |
| if (is_linux || is_mac) { |
| deps += [ ":${target_name}_spec" ] |
| } |
| } |
| } |
| |
| set_defaults("test") { |
| configs = default_executable_configs |
| } |