blob: 5df2219d7e6ecd98aea35a2a82a4990ca40cdc6d [file] [log] [blame]
# Copyright 2021 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/go/go_test.gni")
import("//build/testing/host_test_data.gni")
# Declares a Go test that uses the fidlgentest library.
#
# The fidlgentest library runs fidlc at runtime, so tests using it must make
# fidlc available and pass its path as an argument to the test binary. This
# template takes care of that.
#
# Parameters: same as go_test.
template("fidlgentest_go_test") {
assert(is_host, "The fidlgentest_go_test template can only be used on host")
fidlc_target = "//tools/fidl/fidlc($host_toolchain)"
fidlc_binary = get_label_info(fidlc_target, "root_out_dir") + "/fidlc"
test_data_target = "${target_name}_test_data"
host_test_data(test_data_target) {
visibility = [ ":*" ]
sources = [ fidlc_binary ]
deps = [ fidlc_target ]
}
go_test(target_name) {
forward_variables_from(invoker, "*")
if (!defined(args)) {
args = []
}
args += [
"--fidlc",
rebase_path(fidlc_binary, root_build_dir),
]
if (!defined(deps)) {
deps = []
}
deps += [ "//tools/fidl/lib/fidlgentest" ]
if (!defined(non_go_deps)) {
non_go_deps = []
}
non_go_deps += [ ":$test_data_target" ]
}
}