blob: 45a9dcef41c6cbdb3e91b12e3bd1d7bf6d9922e4 [file] [log] [blame]
# Copyright 2023 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/compiled_action.gni")
import("//build/testing/golden_files.gni")
# Runs testgen and verifies the output matches a set of golden files.
template("testgen_golden_files") {
assert(defined(invoker.comparisons))
assert(defined(invoker.testgen))
testgen = invoker.testgen
assert(defined(testgen.test_root))
assert(defined(testgen.args))
assert(defined(testgen.label))
assert(defined(testgen.inputs))
assert(defined(testgen.outputs))
main_target_name = target_name
action("${target_name}_generate_test") {
forward_variables_from(testgen,
[
"inputs",
"outputs",
])
_binary_root = get_label_info(testgen.label, "root_out_dir")
_binary_name = get_label_info(testgen.label, "name")
_binary = "$_binary_root/$_binary_name"
script = "//tools/testgen/build/gn_testgen.sh"
inputs += [ _binary ]
args = [
rebase_path(testgen.test_root, root_build_dir),
rebase_path(_binary, root_build_dir),
] + testgen.args
deps = [ testgen.label ]
}
golden_files("${target_name}_golden_files") {
testonly = true
deps = [ ":${main_target_name}_generate_test" ]
comparisons = invoker.comparisons
}
group(main_target_name) {
testonly = true
deps = [ ":${target_name}_golden_files" ]
}
}