Skip to content
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

release-23.1: lint: fix TestForbiddenImports #132350

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/testutils/lint/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1546,12 +1546,19 @@ func TestLint(t *testing.T) {
pkgs, err := packages.Load(
&packages.Config{
Mode: packages.NeedImports | packages.NeedName,
Dir: crdbDir,
},
pkgPath,
)
if err != nil {
return errors.Wrapf(err, "error loading package %s", pkgPath)
}
// NB: if no packages were found, this API confusingly
// returns no error, so we need to explicitly check that
// something was returned.
if len(pkgs) == 0 {
return errors.Newf("could not list packages under %s", pkgPath)
}
for _, pkg := range pkgs {
for _, s := range pkg.Imports {
arg.Out <- pkg.PkgPath + ": " + s.PkgPath
Expand Down Expand Up @@ -1583,6 +1590,7 @@ func TestLint(t *testing.T) {
stream.GrepNot(`cockroachdb/cockroach/pkg/kv/kvpb/gen: log$`),
stream.GrepNot(`cockroachdb/cockroach/pkg/util/log/gen: log$`),
stream.GrepNot(`cockroach/pkg/util/uuid: github\.com/satori/go\.uuid$`),
stream.GrepNot(`github.com/cockroachdb/cockroach/pkg/workload/debug: log$`),
), func(s string) {
pkgStr := strings.Split(s, ": ")
importingPkg, importedPkg := pkgStr[0], pkgStr[1]
Expand Down