]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: stop early in disallowInternal on erroneous packages
authorAndrew Gerrand <adg@golang.org>
Mon, 15 Jun 2015 03:19:39 +0000 (13:19 +1000)
committerAndrew Gerrand <adg@golang.org>
Mon, 15 Jun 2015 04:27:27 +0000 (04:27 +0000)
Fixes #11201

Change-Id: I80d8fcfcb5c856aaf9d0e73d756d86018e2bec3b
Reviewed-on: https://go-review.googlesource.com/11110
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/go/go_test.go
src/cmd/go/pkg.go
src/cmd/go/testdata/testinternal3/t.go [new file with mode: 0644]

index cdbdfd79ea1725a8dd0be9861bf066f14670c44a..fd1a63551c0ef682d2617c3e2d34542a5e5310da 100644 (file)
@@ -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")
 }
 
+func TestInternalPackageErrorsAreHandled(t *testing.T) {
+       tg := testgo(t)
+       defer tg.cleanup()
+       tg.run("list", "./testdata/testinternal3")
+}
+
 func TestMoveGit(t *testing.T) {
        testMove(t, "git", "rsc.io/pdf", "pdf", "rsc.io/pdf/.git/config")
 }
index 539ef5bfc6b579556a63cc2aa226743e28f0f2d0..73527a3aba333ceaa77554235a430444936c902f 100644 (file)
@@ -327,6 +327,11 @@ func disallowInternal(srcDir string, p *Package, stk *importStack) *Package {
        // is disallowed if the importing code is outside the tree
        // 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.
        // If that's the only thing on the stack, we started
        // with a name given on the command line, not an
diff --git a/src/cmd/go/testdata/testinternal3/t.go b/src/cmd/go/testdata/testinternal3/t.go
new file mode 100644 (file)
index 0000000..8576a4b
--- /dev/null
@@ -0,0 +1,3 @@
+package t
+
+import _ "internal/does-not-exist"