blob: 00709ff009a6120e176c7374bba9be2f43444635 [file] [log] [blame]
# 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) {
_output_name = target_name
if (defined(invoker.output_name)) {
_output_name = invoker.output_name
}
_output_dir = root_out_dir
if (defined(invoker.output_dir)) {
_output_dir = invoker.output_dir
}
test_spec("${target_name}_spec") {
name = invoker.target_name
target = invoker.target_name
path = "$_output_dir/$_output_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) {
# TODO(3367): remove `test_group` once all ZN tests are using test packages
# instead.
forward_variables_from(invoker, "*", [ "test_group" ])
# TODO(44278): always force `testonly` once all ZN tests are moved to
# packages.
if (!defined(testonly)) {
testonly = true
}
if (is_linux || is_mac) {
deps += [ ":${target_name}_spec" ]
}
if (!defined(output_dir)) {
output_dir = root_out_dir
}
if (defined(output_name)) {
_manifest_output_name = output_name
} else {
output_name = target_name
_manifest_output_name = "$target_name-test"
}
if (!defined(output_extension)) {
output_extension = ""
}
_output_name = output_name
if (output_extension != "") {
_output_name += ".$output_extension"
_manifest_output_name += ".$output_extension"
}
_output_file = rebase_path("$output_dir/$_output_name", root_build_dir)
if (defined(invoker.test_group)) {
_test_group = invoker.test_group
} else {
_test_group = "sys"
}
metadata = {
migrated_manifest_lines =
[ "test/$_test_group/$_manifest_output_name=$_output_file" ]
}
}
}
set_defaults("test") {
configs = default_executable_configs
}