]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix and reenable TestAccidentalGitCheckout
authorRuss Cox <rsc@golang.org>
Sat, 18 Aug 2018 01:25:52 +0000 (21:25 -0400)
committerRuss Cox <rsc@golang.org>
Sat, 18 Aug 2018 18:22:46 +0000 (18:22 +0000)
This is an important security problem so we shouldn't disable the test.
The second half was failing on case-sensitive file systems but the
first half is still good.

Fixes #22983.

Change-Id: I437bb4c9f78eb3177aa8b619e2357b2539566ca9
Reviewed-on: https://go-review.googlesource.com/129797
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/go/go_test.go

index da2dfd3bfb87a70e6732edf35504206c1b18a55a..ec6a72c66a53a3f7b4edecd32660d3d0a72a4e79 100644 (file)
@@ -1291,9 +1291,9 @@ func TestGetGitDefaultBranch(t *testing.T) {
        tg.grepStdout(`\* another-branch`, "not on correct default branch")
 }
 
+// Security issue. Don't disable. See golang.org/issue/22125.
 func TestAccidentalGitCheckout(t *testing.T) {
        testenv.MustHaveExternalNetwork(t)
-       testenv.SkipFlaky(t, 22983) // this test might not have ever worked; see issue.
        if _, err := exec.LookPath("git"); err != nil {
                t.Skip("skipping because git binary not found")
        }
@@ -1302,13 +1302,17 @@ func TestAccidentalGitCheckout(t *testing.T) {
        defer tg.cleanup()
        tg.parallel()
        tg.tempDir("src")
+
        tg.setenv("GOPATH", tg.path("."))
 
        tg.runFail("get", "-u", "vcs-test.golang.org/go/test1-svn-git")
        tg.grepStderr("src[\\\\/]vcs-test.* uses git, but parent .*src[\\\\/]vcs-test.* uses svn", "get did not fail for right reason")
 
-       tg.runFail("get", "-u", "vcs-test.golang.org/go/test2-svn-git/test2main")
-       tg.grepStderr("src[\\\\/]vcs-test.* uses git, but parent .*src[\\\\/]vcs-test.* uses svn", "get did not fail for right reason")
+       if _, err := os.Stat(tg.path("SrC")); err == nil {
+               // This case only triggers on a case-insensitive file system.
+               tg.runFail("get", "-u", "vcs-test.golang.org/go/test2-svn-git/test2main")
+               tg.grepStderr("src[\\\\/]vcs-test.* uses git, but parent .*src[\\\\/]vcs-test.* uses svn", "get did not fail for right reason")
+       }
 }
 
 func TestErrorMessageForSyntaxErrorInTestGoFileSaysFAIL(t *testing.T) {