]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix go list -test where C is a dependency.
authorPaul Jolly <paul@myitcv.io>
Thu, 3 May 2018 07:42:45 +0000 (08:42 +0100)
committerIan Lance Taylor <iant@golang.org>
Tue, 8 May 2018 17:33:20 +0000 (17:33 +0000)
Currently go list -test runtime/cgo fails with an index out of range
error. This appears to be because the updating of import paths that
happens as part of -test doesn't take into account the fact that the
Internal.Imports of a package do not contain "C", whereas the public
Imports do.

Therefore we skip the public Import of "C" if it exists and continue.

Change-Id: I5cdc8968890fa7e5da3e375718606037d3282754
Reviewed-on: https://go-review.googlesource.com/111175
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/go/go_test.go
src/cmd/go/internal/list/list.go

index 2b2e17a71a29bf7b179ba812cca7ea449bdd2643..7fc2197a0854a38c3f0316f832a0d57245f4e8ce 100644 (file)
@@ -1946,6 +1946,9 @@ func TestGoListTest(t *testing.T) {
        tg.grepStdout(`^cmd/doc\.test$`, "missing cmd/doc test")
        tg.grepStdoutNot(`^cmd/dist\.test$`, "unexpected cmd/dist test")
        tg.grepStdoutNot(`^testing`, "unexpected testing")
+
+       tg.run("list", "-test", "runtime/cgo")
+       tg.grepStdout(`^runtime/cgo$`, "missing runtime/cgo")
 }
 
 // Issue 4096. Validate the output of unsuccessful go install foo/quxx.
index 4cd9846ce4bd555ede2c26f90444c65e1f9d3c47..5b242a887a2d87b07bd57bcb0bf2bf770ba20d02 100644 (file)
@@ -318,8 +318,14 @@ func runList(cmd *base.Command, args []string) {
                }
                // Update import path lists to use new strings.
                for _, p := range all {
+                       j := 0
                        for i := range p.Imports {
-                               p.Imports[i] = p.Internal.Imports[i].ImportPath
+                               // Internal skips "C"
+                               if p.Imports[i] == "C" {
+                                       continue
+                               }
+                               p.Imports[i] = p.Internal.Imports[j].ImportPath
+                               j++
                        }
                }
                // Recompute deps lists using new strings, from the leaves up.