]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert TestGoGetInsecure to the script framework
authorMichael Matloob <matloob@golang.org>
Wed, 8 Jan 2020 20:21:39 +0000 (15:21 -0500)
committerMichael Matloob <matloob@golang.org>
Wed, 19 Feb 2020 20:50:20 +0000 (20:50 +0000)
Part of converting all tests to script framework to improve
test parallelism

Updates #36320
Updates #17751

Change-Id: Ic323b643d7149df4fd63b222e820e2dff50686fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/213829
Reviewed-by: Jay Conrod <jayconrod@google.com>
src/cmd/go/go_test.go
src/cmd/go/testdata/script/get_insecure.txt [new file with mode: 0644]

index 5cebddea52df08363ed7d2d7eac0c84762a71d82..afb4cafb57c37a3031592402307dfd5c349f8e0c 100644 (file)
@@ -2552,48 +2552,6 @@ func TestImportLocal(t *testing.T) {
        tg.grepStderr("cannot import current directory", "did not diagnose import current directory")
 }
 
-func TestGoGetInsecure(t *testing.T) {
-       test := func(t *testing.T, modules bool) {
-               testenv.MustHaveExternalNetwork(t)
-               testenv.MustHaveExecPath(t, "git")
-
-               tg := testgo(t)
-               defer tg.cleanup()
-               tg.makeTempdir()
-               tg.failSSH()
-
-               if modules {
-                       tg.setenv("GOPATH", tg.path("gp"))
-                       tg.tempFile("go.mod", "module m")
-                       tg.cd(tg.path("."))
-                       tg.setenv("GO111MODULE", "on")
-                       tg.setenv("GOPROXY", "")
-               } else {
-                       tg.setenv("GOPATH", tg.path("."))
-                       tg.setenv("GO111MODULE", "off")
-               }
-
-               const repo = "insecure.go-get-issue-15410.appspot.com/pkg/p"
-
-               // Try go get -d of HTTP-only repo (should fail).
-               tg.runFail("get", "-d", repo)
-
-               // Try again with -insecure (should succeed).
-               tg.run("get", "-d", "-insecure", repo)
-
-               // Try updating without -insecure (should fail).
-               tg.runFail("get", "-d", "-u", "-f", repo)
-
-               if modules {
-                       tg.run("list", "-m", "...")
-                       tg.grepStdout("insecure.go-get-issue", "should find insecure module")
-               }
-       }
-
-       t.Run("gopath", func(t *testing.T) { test(t, false) })
-       t.Run("modules", func(t *testing.T) { test(t, true) })
-}
-
 func TestGoGetUpdateInsecure(t *testing.T) {
        testenv.MustHaveExternalNetwork(t)
        testenv.MustHaveExecPath(t, "git")
diff --git a/src/cmd/go/testdata/script/get_insecure.txt b/src/cmd/go/testdata/script/get_insecure.txt
new file mode 100644 (file)
index 0000000..36ad2c0
--- /dev/null
@@ -0,0 +1,51 @@
+# TODO(matloob): Split this test into two? It's one of the slowest tests we have.
+
+[!net] skip
+[!exec:git] skip
+
+env PATH=$WORK/tmp/bin${:}$PATH
+go build -o $WORK/tmp/bin/ssh ssh.go
+
+# GOPATH: Set up
+env GO111MODULE=off
+
+# GOPATH: Try go get -d of HTTP-only repo (should fail).
+! go get -d insecure.go-get-issue-15410.appspot.com/pkg/p
+
+# GOPATH: Try again with -insecure (should succeed).
+go get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p
+
+# GOPATH: Try updating without -insecure (should fail).
+! go get -d -u -f insecure.go-get-issue-15410.appspot.com/pkg/p
+
+# Modules: Set up
+env GOPATH=$WORK/m/gp
+mkdir $WORK/m
+cp module_file $WORK/m/go.mod
+cd $WORK/m
+env GO111MODULE=on
+env GOPROXY=''
+
+# Modules: Try go get -d of HTTP-only repo (should fail).
+! go get -d insecure.go-get-issue-15410.appspot.com/pkg/p
+
+# Modules: Try again with -insecure (should succeed).
+go get -d -insecure insecure.go-get-issue-15410.appspot.com/pkg/p
+
+# Modules: Try updating without -insecure (should fail).
+! go get -d -u -f insecure.go-get-issue-15410.appspot.com/pkg/p
+
+go list -m ...
+stdout 'insecure.go-get-issue'
+
+-- ssh.go --
+// stub out uses of ssh by go get
+package main
+
+import "os"
+
+func main() {
+       os.Exit(1)
+}
+-- module_file --
+module m
\ No newline at end of file