Skip to content

Commit b28808d

Browse files
matloobgopherbot
authored andcommitted
cmd/go/internal/modindex: fix obvious bug using failed type assertion
adonovan pointed out this bug in the review of CL 733320 and this seems to be the cause of all those list_empty_importpath flakes. It makes sense that something nondeterministic would be tied up with the module index because the state of the cache could depend on the order tests are run in. Also remove the parts of the test that accept the flaky behavior so we can verify the issue has been resolved. For #73976 Change-Id: Ib64ce6b8eed1dc8d327b7c5e842c1e716a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/733321 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com>
1 parent d64add4 commit b28808d

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

src/cmd/go/internal/modindex/scan.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ func parseErrorToString(err error) string {
112112
return ""
113113
}
114114
var p parseError
115-
if e, ok := err.(scanner.ErrorList); ok {
116-
p.ErrorList = &e
115+
if errlist, ok := err.(scanner.ErrorList); ok {
116+
p.ErrorList = &errlist
117117
} else {
118-
p.ErrorString = e.Error()
118+
p.ErrorString = err.Error()
119119
}
120120
s, err := json.Marshal(p)
121121
if err != nil {

src/cmd/go/testdata/script/list_empty_importpath.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
! go list all
22
! stderr 'panic'
3-
[!GOOS:windows] [!GOOS:solaris] [!GOOS:freebsd] [!GOOS:openbsd] [!GOOS:netbsd] stderr 'invalid import path'
4-
# #73976: Allow 'no errors' on Windows, Solaris, and BSD until issue
5-
# is resolved to prevent flakes. 'no errors' is printed by
6-
# empty scanner.ErrorList errors so that's probably where the
7-
# message is coming from, though we don't know how.
8-
[GOOS:windows] stderr 'invalid import path|no errors'
9-
[GOOS:solaris] stderr 'invalid import path|no errors'
10-
[GOOS:freebsd] stderr 'invalid import path|no errors'
11-
[GOOS:openbsd] stderr 'invalid import path|no errors'
12-
[GOOS:netbsd] stderr 'invalid import path|no errors'
3+
stderr 'invalid import path'
134

145
# go list produces a package for 'p' but not for ''
156
go list -e all

0 commit comments

Comments
 (0)