Skip to content

Commit

Permalink
internal/gcimporter: use nondeprecated go/packages mode bits
Browse files Browse the repository at this point in the history
I meant to do this in the first CL, but was prevented by
a bug which I have since reported and linked to from the code.

Change-Id: I651e728c535cdeb0885eae4d510fda3c24518dcf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/448376
Auto-Submit: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
adonovan authored and gopherbot committed Nov 7, 2022
1 parent 5050657 commit 003fde1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions internal/gcimporter/shallow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ func TestShallowStd(t *testing.T) {
// Load import graph of the standard library.
// (No parsing or type-checking.)
cfg := &packages.Config{
Mode: packages.LoadImports,
Mode: packages.NeedImports |
packages.NeedName |
packages.NeedFiles | // see https://github.com/golang/go/issues/56632
packages.NeedCompiledGoFiles,
Tests: false,
}
pkgs, err := packages.Load(cfg, "std")
Expand Down Expand Up @@ -111,7 +114,6 @@ func typecheck(t *testing.T, ppkg *packages.Package) {
insert func(p *types.Package, name string)
importMap = make(map[string]*types.Package) // keys are PackagePaths
)

loadFromExportData := func(imp *packages.Package) (*types.Package, error) {
data := []byte(imp.ExportFile)
return gcimporter.IImportShallow(fset, importMap, data, imp.PkgPath, insert)
Expand All @@ -125,13 +127,12 @@ func typecheck(t *testing.T, ppkg *packages.Package) {
if err != nil {
t.Fatalf("unmarshal: %v", err)
}
obj := imported.Scope().Lookup(name)
if obj == nil {
t.Fatalf("lookup %q.%s failed", imported.Path(), name)
}
if imported != p {
t.Fatalf("internal error: inconsistent packages")
}
if obj := imported.Scope().Lookup(name); obj == nil {
t.Fatalf("lookup %q.%s failed", imported.Path(), name)
}
}

cfg := &types.Config{
Expand Down

0 comments on commit 003fde1

Please sign in to comment.