-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testutils/buildutil: add disallowed_imports_test bazel macro #79299
testutils/buildutil: add disallowed_imports_test bazel macro #79299
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also update generate-test-suites
so we can start finding and running these tests in CI.
diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel
index fda6ded3a1..8e2b8584c4 100644
--- a/pkg/BUILD.bazel
+++ b/pkg/BUILD.bazel
@@ -266,6 +266,7 @@ ALL_TESTS = [
"//pkg/sql/doctor:doctor_test",
"//pkg/sql/enum:enum_test",
"//pkg/sql/execinfra:execinfra_test",
+ "//pkg/sql/execinfrapb:execinfrapb_disallowed_imports_test",
"//pkg/sql/execinfrapb:execinfrapb_test",
"//pkg/sql/execstats:execstats_test",
"//pkg/sql/flowinfra:flowinfra_test",
diff --git a/pkg/cmd/generate-test-suites/main.go b/pkg/cmd/generate-test-suites/main.go
index 3a2a62b867..0c4481b34d 100644
--- a/pkg/cmd/generate-test-suites/main.go
+++ b/pkg/cmd/generate-test-suites/main.go
@@ -39,7 +39,7 @@ func main() {
packagesToQuery = append(packagesToQuery, fmt.Sprintf("//pkg/%s/...", info.Name()))
}
allPackages := strings.Join(packagesToQuery, "+")
- queryArgs := []string{"query", fmt.Sprintf("kind(go_test, %s)", allPackages), "--output=label"}
+ queryArgs := []string{"query", fmt.Sprintf("kind(go_test, %s) union kind(sh_test, %s)", allPackages, allPackages), "--output=label"}
buf, err := exec.Command("bazel", queryArgs...).Output()
if err != nil {
log.Printf("Could not query Bazel tests: got error %v", err)
7794077
to
a0655be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Reviewable status: complete! 0 of 0 LGTMs obtained
This macro can be used to create a test which disallows one go package from importing another. It uses a thin aspect to accumulate go dependencies while avoiding any cycle due to nogo. There's an example of its use in `execinfrapb`. It also ensures that we generate the tests into the BUILD.bazel file so they are run by CI. Relates heavily to cockroachdb#74176. Release note: None
a0655be
to
cd890f5
Compare
TFTR! bors r=rickystewart |
Build failed (retrying...): |
Build succeeded: |
This macro can be used to create a test which disallows one go package from
importing another. It uses a thin aspect to accumulate go dependencies while
avoiding any cycle due to nogo.
There's an example of its use in
execinfrapb
.Relates heavily to #74176.
Release note: None
Jira issue: CRDB-14797