|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") |
|
|
|
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") |
|
|
|
load("//rust:aspects.bzl", "RustProtoInfo") |
|
|
|
load("//rust:aspects.bzl", "RustProtoInfo") |
|
|
|
|
|
|
|
load("//rust:defs.bzl", "rust_cc_proto_library", "rust_upb_proto_library") |
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_proto_library") |
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_proto_library") |
|
|
|
load(":defs.bzl", "ActionsInfo", "attach_cc_aspect", "attach_upb_aspect") |
|
|
|
load(":defs.bzl", "ActionsInfo", "attach_cc_aspect", "attach_upb_aspect") |
|
|
|
|
|
|
|
|
|
|
@ -168,6 +169,43 @@ def _test_cc_aspect(): |
|
|
|
|
|
|
|
|
|
|
|
#################################################################################################### |
|
|
|
#################################################################################################### |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _rust_outputs_test_impl(ctx): |
|
|
|
|
|
|
|
env = analysistest.begin(ctx) |
|
|
|
|
|
|
|
target_under_test = analysistest.target_under_test(env) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
label_to_file = { |
|
|
|
|
|
|
|
"child_rust_cc_proto": "child.c.pb.rs", |
|
|
|
|
|
|
|
"child_rust_upb_proto": "child.u.pb.rs", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
expected_output = label_to_file[target_under_test.label.name] |
|
|
|
|
|
|
|
asserts.true(env, target_under_test.files.to_list()[0].path.endswith(expected_output)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return analysistest.end(env) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rust_outputs_test = analysistest.make(_rust_outputs_test_impl) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _test_cc_outputs(): |
|
|
|
|
|
|
|
rust_cc_proto_library( |
|
|
|
|
|
|
|
name = "child_rust_cc_proto", |
|
|
|
|
|
|
|
deps = [":child_proto"], |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rust_outputs_test( |
|
|
|
|
|
|
|
name = "rust_cc_outputs_test", |
|
|
|
|
|
|
|
target_under_test = ":child_rust_cc_proto", |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _test_upb_outputs(): |
|
|
|
|
|
|
|
rust_upb_proto_library( |
|
|
|
|
|
|
|
name = "child_rust_upb_proto", |
|
|
|
|
|
|
|
deps = [":child_proto"], |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rust_outputs_test( |
|
|
|
|
|
|
|
name = "rust_upb_outputs_test", |
|
|
|
|
|
|
|
target_under_test = ":child_rust_upb_proto", |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
def rust_proto_library_unit_test(name): |
|
|
|
def rust_proto_library_unit_test(name): |
|
|
|
"""Sets up rust_proto_library_unit_test test suite. |
|
|
|
"""Sets up rust_proto_library_unit_test test suite. |
|
|
|
|
|
|
|
|
|
|
@ -196,11 +234,15 @@ def rust_proto_library_unit_test(name): |
|
|
|
|
|
|
|
|
|
|
|
_test_upb_aspect() |
|
|
|
_test_upb_aspect() |
|
|
|
_test_cc_aspect() |
|
|
|
_test_cc_aspect() |
|
|
|
|
|
|
|
_test_cc_outputs() |
|
|
|
|
|
|
|
_test_upb_outputs() |
|
|
|
|
|
|
|
|
|
|
|
native.test_suite( |
|
|
|
native.test_suite( |
|
|
|
name = name, |
|
|
|
name = name, |
|
|
|
tests = [ |
|
|
|
tests = [ |
|
|
|
":rust_upb_aspect_test", |
|
|
|
":rust_upb_aspect_test", |
|
|
|
":rust_cc_aspect_test", |
|
|
|
":rust_cc_aspect_test", |
|
|
|
|
|
|
|
":rust_cc_outputs_test", |
|
|
|
|
|
|
|
":rust_upb_outputs_test", |
|
|
|
], |
|
|
|
], |
|
|
|
) |
|
|
|
) |
|
|
|