Skip to content

Commit 003fde1

Browse files
adonovangopherbot
authored andcommitted
internal/gcimporter: use nondeprecated go/packages mode bits
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 <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Robert Findley <[email protected]> Run-TryBot: Alan Donovan <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 5050657 commit 003fde1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

internal/gcimporter/shallow_test.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ func TestShallowStd(t *testing.T) {
2828
// Load import graph of the standard library.
2929
// (No parsing or type-checking.)
3030
cfg := &packages.Config{
31-
Mode: packages.LoadImports,
31+
Mode: packages.NeedImports |
32+
packages.NeedName |
33+
packages.NeedFiles | // see https://github.com/golang/go/issues/56632
34+
packages.NeedCompiledGoFiles,
3235
Tests: false,
3336
}
3437
pkgs, err := packages.Load(cfg, "std")
@@ -111,7 +114,6 @@ func typecheck(t *testing.T, ppkg *packages.Package) {
111114
insert func(p *types.Package, name string)
112115
importMap = make(map[string]*types.Package) // keys are PackagePaths
113116
)
114-
115117
loadFromExportData := func(imp *packages.Package) (*types.Package, error) {
116118
data := []byte(imp.ExportFile)
117119
return gcimporter.IImportShallow(fset, importMap, data, imp.PkgPath, insert)
@@ -125,13 +127,12 @@ func typecheck(t *testing.T, ppkg *packages.Package) {
125127
if err != nil {
126128
t.Fatalf("unmarshal: %v", err)
127129
}
128-
obj := imported.Scope().Lookup(name)
129-
if obj == nil {
130-
t.Fatalf("lookup %q.%s failed", imported.Path(), name)
131-
}
132130
if imported != p {
133131
t.Fatalf("internal error: inconsistent packages")
134132
}
133+
if obj := imported.Scope().Lookup(name); obj == nil {
134+
t.Fatalf("lookup %q.%s failed", imported.Path(), name)
135+
}
135136
}
136137

137138
cfg := &types.Config{

0 commit comments

Comments
 (0)