Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buildutil: fix disallowed_imports_test to propagate deps via embed
Before this change we wouldn't track the dependencies inherited via embedded targets. This does add some cruft because some embedded targets are not `go_library` targets but rather are things like `go_proto_library` so we have to check whether the targets have certain attributes. The aspect docs make it seem like this is normal. Before this change, the following would not fail, now it will: ``` --- a/pkg/cmd/cockroach/BUILD.bazel +++ b/pkg/cmd/cockroach/BUILD.bazel @@ -1,5 +1,6 @@ load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data") load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("//pkg/testutils/buildutil:buildutil.bzl", "disallowed_imports_test") go_library( name = "cockroach_lib", @@ -20,4 +21,11 @@ go_binary( visibility = ["//visibility:public"], ) +disallowed_imports_test( + "cockroach", + disallowed_list = [ + "//pkg/sql/randgen:randgen", + ], +) + ``` ``` ERROR: //pkg/cmd/cockroach:cockroach imports //pkg/sql/randgen:randgen check: bazel query 'somepath(//pkg/cmd/cockroach:cockroach, //pkg/sql/randgen:randgen)' ``` Epic: none Release note: None
- Loading branch information