Commit d14e9e63 authored by Andrew Gerrand's avatar Andrew Gerrand

cmd/go: stop early in disallowInternal on erroneous packages

Fixes #11201

Change-Id: I80d8fcfcb5c856aaf9d0e73d756d86018e2bec3b
Reviewed-on: https://go-review.googlesource.com/11110Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 7d48237f
...@@ -875,6 +875,12 @@ func testMove(t *testing.T, vcs, url, base, config string) { ...@@ -875,6 +875,12 @@ func testMove(t *testing.T, vcs, url, base, config string) {
tg.grepStderr("validating server certificate|not found", "go get -d -f -u "+url+" failed for wrong reason") tg.grepStderr("validating server certificate|not found", "go get -d -f -u "+url+" failed for wrong reason")
} }
func TestInternalPackageErrorsAreHandled(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.run("list", "./testdata/testinternal3")
}
func TestMoveGit(t *testing.T) { func TestMoveGit(t *testing.T) {
testMove(t, "git", "rsc.io/pdf", "pdf", "rsc.io/pdf/.git/config") testMove(t, "git", "rsc.io/pdf", "pdf", "rsc.io/pdf/.git/config")
} }
......
...@@ -327,6 +327,11 @@ func disallowInternal(srcDir string, p *Package, stk *importStack) *Package { ...@@ -327,6 +327,11 @@ func disallowInternal(srcDir string, p *Package, stk *importStack) *Package {
// is disallowed if the importing code is outside the tree // is disallowed if the importing code is outside the tree
// rooted at the parent of the “internal” directory. // rooted at the parent of the “internal” directory.
// There was an error loading the package; stop here.
if p.Error != nil {
return p
}
// The stack includes p.ImportPath. // The stack includes p.ImportPath.
// If that's the only thing on the stack, we started // If that's the only thing on the stack, we started
// with a name given on the command line, not an // with a name given on the command line, not an
......
package t
import _ "internal/does-not-exist"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment