| # Copyright 2017 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. |
| |
| # A template for an action that creates a Fuchsia Go test binary. |
| |
| import("//build/go/go_build.gni") |
| |
| # Parameters: same as go_build, along with |
| # |
| # gopackages |
| # Required: The go packages containing the tests to be run. |
| # Type: list of strings. |
| # |
| # args |
| # Optional: additional arguments needed when invoking the test. |
| # Type: list of strings. |
| # |
| # disabled |
| # Optional: whether the test is disabled. |
| # Type: bool |
| # Default: false |
| # |
| # 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("go_test") { |
| _main_target_name = target_name |
| |
| output_name = "tests/go/$target_name" |
| if (defined(invoker.output_name)) { |
| output_name = "tests/go/${invoker.output_name}" |
| } |
| _output_path = "${root_out_dir}/${output_name}" |
| |
| go_build(_main_target_name) { |
| test = true |
| output_name = output_name |
| forward_variables_from(invoker, |
| "*", |
| [ |
| "disabled", |
| "environments", |
| "output_name", |
| ]) |
| } |
| |
| _outputs = get_target_outputs(":$_main_target_name") |
| assert(_outputs[0] == _output_path) |
| } |