aboutsummaryrefslogtreecommitdiff
path: root/go/packages/packages_test.go
diff options
context:
space:
mode:
authorAlex Zhirov <azhirov@google.com>2019-12-20 21:46:56 +0000
committerMichael Matloob <matloob@golang.org>2019-12-20 22:49:55 +0000
commite5a4a00f6f35b6b62072594fb2437566347955ec (patch)
treeb23928df7442b0b8082ba26bd05132266c7dc9ce /go/packages/packages_test.go
parent2f6d8bf0ad77a8a81251456588966c51ed5044d1 (diff)
downloadgolang-x-tools-e5a4a00f6f35b6b62072594fb2437566347955ec.tar.gz
go/packages: Fix loading syntax for imports when types not requested.
http://golang.org/cl/205160 fixed an issue when package syntax wasn't loaded unless NeedTypes was specified, but syntax of imported packages wasn't loaded even with NeedDeps specified. This change corrects this error. Fixes issue #35331. Change-Id: If6d78f01eb59d406e44ab6746f2da9e797bbf8e2 GitHub-Last-Rev: e81ddd0903b1322f2d642349c340d60310cf00f0 GitHub-Pull-Request: golang/tools#189 Reviewed-on: https://go-review.googlesource.com/c/tools/+/208597 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'go/packages/packages_test.go')
-rw-r--r--go/packages/packages_test.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/go/packages/packages_test.go b/go/packages/packages_test.go
index 5d286e900..94bff03f1 100644
--- a/go/packages/packages_test.go
+++ b/go/packages/packages_test.go
@@ -2470,13 +2470,15 @@ func testIssue35331(t *testing.T, exporter packagestest.Exporter) {
if len(pkgs) != 1 {
t.Fatalf("Expected 1 package, got %v", pkgs)
}
- pkg := pkgs[0]
- if len(pkg.Errors) > 0 {
- t.Fatalf("Expected no errors in package, got %v", pkg.Errors)
- }
- if len(pkg.Syntax) == 0 {
- t.Fatalf("Expected syntax on package, got none.")
- }
+ packages.Visit(pkgs, func(pkg *packages.Package) bool {
+ if len(pkg.Errors) > 0 {
+ t.Errorf("Expected no errors in package %q, got %v", pkg.ID, pkg.Errors)
+ }
+ if len(pkg.Syntax) == 0 && pkg.ID != "unsafe" {
+ t.Errorf("Expected syntax on package %q, got none.", pkg.ID)
+ }
+ return true
+ }, nil)
}
func TestLoadModeStrings(t *testing.T) {