]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: don't reject ./... matching top-level file outside GOPATH
authorIan Lance Taylor <iant@golang.org>
Wed, 25 Jan 2017 14:25:17 +0000 (06:25 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 26 Jan 2017 14:41:37 +0000 (14:41 +0000)
This unwinds a small part of CL 31668: we now accept "./." in cleanImport.

Fixes #18778.

Change-Id: Ia7f1fde1cafcea3cc9e0b597a95a0e0bb410a3ed
Reviewed-on: https://go-review.googlesource.com/35646
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/go/go_test.go
src/cmd/go/pkg.go

index 5727eb094e5473a1b5eadaed70a53e16aa9f0ef9..f26c3660e4b809a1ea76d13b4d1a2176fdf419d4 100644 (file)
@@ -3787,3 +3787,26 @@ GLOBL ·constants<>(SB),8,$8
        tg.setenv("GOPATH", tg.path("go"))
        tg.run("build", "p")
 }
+
+// Issue 18778.
+func TestDotDotDotOutsideGOPATH(t *testing.T) {
+       tg := testgo(t)
+       defer tg.cleanup()
+
+       tg.tempFile("pkgs/a.go", `package x`)
+       tg.tempFile("pkgs/a_test.go", `package x_test
+import "testing"
+func TestX(t *testing.T) {}`)
+
+       tg.tempFile("pkgs/a/a.go", `package a`)
+       tg.tempFile("pkgs/a/a_test.go", `package a_test
+import "testing"
+func TestA(t *testing.T) {}`)
+
+       tg.cd(tg.path("pkgs"))
+       tg.run("build", "./...")
+       tg.run("test", "./...")
+       tg.run("list", "./...")
+       tg.grepStdout("pkgs$", "expected package not listed")
+       tg.grepStdout("pkgs/a", "expected package not listed")
+}
index d69fa5118f520c374f305b02a8f422b7df861bc2..e40f9420c7e2217f9e126cf5f636c282c532d959 100644 (file)
@@ -429,7 +429,7 @@ func setErrorPos(p *Package, importPos []token.Position) *Package {
 func cleanImport(path string) string {
        orig := path
        path = pathpkg.Clean(path)
-       if strings.HasPrefix(orig, "./") && path != ".." && path != "." && !strings.HasPrefix(path, "../") {
+       if strings.HasPrefix(orig, "./") && path != ".." && !strings.HasPrefix(path, "../") {
                path = "./" + path
        }
        return path