blob: ed4a6ae1826efe0ae4d3b9a8b087f00720f083a4 [file] [log] [blame]
# Copyright 2020 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_library.gni")
import("//build/go/go_test.gni")
import("//build/json/validate_json.gni")
import("//tools/fidl/fidlc/testdata/info.gni")
group("tests") {
testonly = true
deps = [
":fidlgen_lib_test($host_toolchain)",
":roundtrip_tests($default_toolchain)",
]
}
# These tests perform a round-trip of the IR: valid JSON IR is read into its go
# representation by the library utilities, unmarshaled back to JSON, and then
# validated again as IR. This ensures that the library - and thus all backends
# that depend on it - have an accurate representation of the IR.
if (current_toolchain == default_toolchain) {
roundtrip_test_deps = []
foreach(info, fidl_testdata_info) {
roundtrip_target = "roundtrip.${info.name}"
validate_target = "validate.${info.name}"
output_json = "$target_gen_dir/${info.name}.json"
compiled_action(roundtrip_target) {
testonly = true
visibility = [ ":$validate_target" ]
input_json = "${info.fidl_gen_dir}/${info.target_name}.fidl.json"
inputs = [ input_json ]
outputs = [ output_json ]
tool = "testing:roundtripper"
args = [
"-in",
rebase_path(input_json, root_build_dir),
"-out",
rebase_path(output_json, root_build_dir),
]
deps = [ "${info.target}($fidl_toolchain)" ]
}
validate_json(validate_target) {
testonly = true
visibility = [ ":*" ]
data = output_json
schema = "//tools/fidl/fidlc/schema.json"
deps = [ ":$roundtrip_target" ]
# TODO(https://fxbug.dev/42168969): Update schema to
# "http://json-schema.org/draft-07/schema#" and remove this line.
use_valico = false
}
roundtrip_test_deps += [ ":$validate_target" ]
}
group("roundtrip_tests") {
testonly = true
deps = roundtrip_test_deps
}
}
## BAZEL2GN SENTINEL - DO NOT EDIT BELOW THIS LINE ##
#
# ________ _________ ________ ________
# |\ ____\|\___ ___\\ __ \|\ __ \
# \ \ \___|\|___ \ \_\ \ \|\ \ \ \|\ \
# \ \_____ \ \ \ \ \ \ \\\ \ \ ____\
# \|____|\ \ \ \ \ \ \ \\\ \ \ \___|
# ____\_\ \ \ \__\ \ \_______\ \__\
# |\_________\ \|__| \|_______|\|__|
# \|_________|
#
#
# AUTO-GENERATED - DO NOT EDIT
#
# The targets below are auto-generated based on the targets defined in the
# BUILD.bazel file from the same directory. If you made changes to targets in
# Bazel, instead of editing this file manually, run:
#
# > fx bazel2gn
#
# Please do NOT edit this file directly. Instead, edit the BUILD.bazel file and
# rerun bazel2gn.
import("//build/tools/bazel2gn/bazel_migration.gni")
# A self-verification target for generated content in this file.
if (is_host) {
verify_bazel2gn("verify_bazel2gn") {
}
}
if (is_host) {
go_library("fidlgen") {
sources = [
"formatter.go",
"generator.go",
"identifiers.go",
"names.go",
"reserved_names.go",
"strings.go",
"struct.go",
"templates.go",
"types.go",
"write_file_if_changed.go",
]
importpath = "go.fuchsia.dev/fuchsia/tools/fidl/lib/fidlgen"
}
}
if (is_host) {
go_test("fidlgen_lib_test") {
sources = [
"identifiers_test.go",
"names_test.go",
"strings_test.go",
"struct_test.go",
"types_test.go",
]
embed = [ ":fidlgen" ]
deps = [
"//third_party/golibs:github.com/google/go-cmp/cmp",
"//third_party/golibs:github.com/google/go-cmp/cmp/cmpopts",
]
}
}