Skip to content

Commit

Permalink
Merge pull request cockroachdb#132351 from rickystewart/backport23.2-…
Browse files Browse the repository at this point in the history
…132263

release-23.2: lint: fix `TestForbiddenImports`
  • Loading branch information
rickystewart authored Oct 11, 2024
2 parents 2e4e4f4 + 63a0968 commit e8bf1f4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/testutils/lint/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1629,12 +1629,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 @@ -1666,6 +1673,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

0 comments on commit e8bf1f4

Please sign in to comment.