From 97d5cb24b10b7b740de2f1cc04d88341c4437ae0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=AD?= Date: Fri, 21 Dec 2018 00:04:18 +0100 Subject: [PATCH] cmd/go: add regression test for cryptic vcs errors MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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í TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills --- .../go/testdata/script/mod_vcs_missing.txt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cmd/go/testdata/script/mod_vcs_missing.txt b/src/cmd/go/testdata/script/mod_vcs_missing.txt index fb146b4415..009bb91c3c 100644 --- a/src/cmd/go/testdata/script/mod_vcs_missing.txt +++ b/src/cmd/go/testdata/script/mod_vcs_missing.txt @@ -4,8 +4,25 @@ env GO111MODULE=on env GOPROXY= +cd empty ! go list launchpad.net/gocheck stderr '"bzr": executable file not found' +cd .. --- go.mod -- +# 1.11 used to give the cryptic error "cannot find module for path" here, but +# only for a main package. +cd main +! go build +stderr '"bzr": executable file not found' +cd .. + +-- empty/go.mod -- +module m +-- main/go.mod -- module m +-- main/main.go -- +package main + +import _ "launchpad.net/gocheck" + +func main() {} -- 2.50.0