Skip to content

Commit 97d5cb2

Browse files
committed
cmd/go: add regression test for cryptic vcs errors
On Go 1.11.x, if one ran 'go build' on a main package within a module, while a needed vcs program like git was missing, a confusing error would show up: build testmod: cannot find module for path rsc.io/quote The error should instead point at the source of the problem, which is the missing vcs program. Thankfully, Go 1.12 doesn't have this bug, even though it doesn't seem like the bug was fixed directly and intentionally. To ensure that this particular edge case isn't broken again, add a regression test. Piggyback on mod_vcs_missing, since it already requires a missing vcs program and network access. I double-checked that Go 1.11 fails this test via /usr/bin/go, which is 1.11.3 on my system: $ PATH=~/tip/bin go test -v -run Script/mod_vcs_missing [...] > exec /usr/bin/go build [stderr] build m: cannot find module for path launchpad.net/gocheck Fixes #28948. Change-Id: Iff1bcf77d9f7c11d15935cb87d6f58d7981d33d2 Reviewed-on: https://go-review.googlesource.com/c/155537 Run-TryBot: Daniel Martí <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent 3a3b98f commit 97d5cb2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,25 @@
44
env GO111MODULE=on
55
env GOPROXY=
66

7+
cd empty
78
! go list launchpad.net/gocheck
89
stderr '"bzr": executable file not found'
10+
cd ..
911

10-
-- go.mod --
12+
# 1.11 used to give the cryptic error "cannot find module for path" here, but
13+
# only for a main package.
14+
cd main
15+
! go build
16+
stderr '"bzr": executable file not found'
17+
cd ..
18+
19+
-- empty/go.mod --
20+
module m
21+
-- main/go.mod --
1122
module m
23+
-- main/main.go --
24+
package main
25+
26+
import _ "launchpad.net/gocheck"
27+
28+
func main() {}

0 commit comments

Comments
 (0)