]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: convert some go get tests to the script framework
authorMichael Matloob <matloob@golang.org>
Thu, 9 Jan 2020 21:34:29 +0000 (16:34 -0500)
committerMichael Matloob <matloob@golang.org>
Wed, 19 Feb 2020 20:58:22 +0000 (20:58 +0000)
Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I1de2b428ea7dac5429020742bf12bea910a02079
Reviewed-on: https://go-review.googlesource.com/c/go/+/214141
Reviewed-by: Jay Conrod <jayconrod@google.com>
13 files changed:
src/cmd/go/go_test.go
src/cmd/go/testdata/script/get_custom_domain_wildcard.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_dash_t.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_domain_root.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_dot_slash_download.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_goroot.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_internal_wildcard.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_issue11307.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_race.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_test_only.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_update.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_update_all.txt [new file with mode: 0644]
src/cmd/go/testdata/script/get_update_wildcard.txt [new file with mode: 0644]

index 6955236e78c9b4bac226b42a64aa964a31ce00a2..89c949a6149beeac3331b06d1d46ea21277cc4d8 100644 (file)
@@ -1204,18 +1204,6 @@ func TestPackageNotStaleWithTrailingSlash(t *testing.T) {
        tg.wantNotStale("io", "", "with trailing slash in GOROOT, io listed as stale")
 }
 
-func TestGoGetTestOnlyPkg(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.tempDir("gopath")
-       tg.setenv("GOPATH", tg.path("gopath"))
-       tg.run("get", "golang.org/x/tour/content...")
-       tg.run("get", "-t", "golang.org/x/tour/content...")
-}
-
 // Issue 4104.
 func TestGoTestWithPackageListedMultipleTimes(t *testing.T) {
        tooSlow(t)
@@ -1546,57 +1534,6 @@ func TestDefaultGOPATHPrintedSearchList(t *testing.T) {
        tg.grepStderr(regexp.QuoteMeta(tg.path("home/go/src/github.com/golang/example/hello"))+`.*from \$GOPATH`, "expected default GOPATH")
 }
 
-// Issue 4186. go get cannot be used to download packages to $GOROOT.
-// Test that without GOPATH set, go get should fail.
-func TestGoGetIntoGOROOT(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.parallel()
-       tg.tempDir("src")
-
-       // Fails because GOROOT=GOPATH
-       tg.setenv("GOPATH", tg.path("."))
-       tg.setenv("GOROOT", tg.path("."))
-       tg.runFail("get", "-d", "github.com/golang/example/hello")
-       tg.grepStderr("warning: GOPATH set to GOROOT", "go should detect GOPATH=GOROOT")
-       tg.grepStderr(`\$GOPATH must not be set to \$GOROOT`, "go should detect GOPATH=GOROOT")
-
-       // Fails because GOROOT=GOPATH after cleaning.
-       tg.setenv("GOPATH", tg.path(".")+"/")
-       tg.setenv("GOROOT", tg.path("."))
-       tg.runFail("get", "-d", "github.com/golang/example/hello")
-       tg.grepStderr("warning: GOPATH set to GOROOT", "go should detect GOPATH=GOROOT")
-       tg.grepStderr(`\$GOPATH must not be set to \$GOROOT`, "go should detect GOPATH=GOROOT")
-
-       tg.setenv("GOPATH", tg.path("."))
-       tg.setenv("GOROOT", tg.path(".")+"/")
-       tg.runFail("get", "-d", "github.com/golang/example/hello")
-       tg.grepStderr("warning: GOPATH set to GOROOT", "go should detect GOPATH=GOROOT")
-       tg.grepStderr(`\$GOPATH must not be set to \$GOROOT`, "go should detect GOPATH=GOROOT")
-
-       // Fails because GOROOT=$HOME/go so default GOPATH unset.
-       tg.tempDir("home/go")
-       tg.setenv(homeEnvName(), tg.path("home"))
-       tg.setenv("GOPATH", "")
-       tg.setenv("GOROOT", tg.path("home/go"))
-       tg.runFail("get", "-d", "github.com/golang/example/hello")
-       tg.grepStderr(`\$GOPATH not set`, "expected GOPATH not set")
-
-       tg.setenv(homeEnvName(), tg.path("home")+"/")
-       tg.setenv("GOPATH", "")
-       tg.setenv("GOROOT", tg.path("home/go"))
-       tg.runFail("get", "-d", "github.com/golang/example/hello")
-       tg.grepStderr(`\$GOPATH not set`, "expected GOPATH not set")
-
-       tg.setenv(homeEnvName(), tg.path("home"))
-       tg.setenv("GOPATH", "")
-       tg.setenv("GOROOT", tg.path("home/go")+"/")
-       tg.runFail("get", "-d", "github.com/golang/example/hello")
-       tg.grepStderr(`\$GOPATH not set`, "expected GOPATH not set")
-}
-
 func TestLdflagsArgumentsWithSpacesIssue3941(t *testing.T) {
        skipIfGccgo(t, "gccgo does not support -ldflags -X")
        tooSlow(t)
@@ -1879,35 +1816,6 @@ func TestSymlinkWarning(t *testing.T) {
        tg.grepStderr("ignoring symlink", "list should have reported symlink")
 }
 
-// Issue 8181.
-func TestGoGetDashTIssue8181(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.parallel()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "-v", "-t", "github.com/rsc/go-get-issue-8181/a", "github.com/rsc/go-get-issue-8181/b")
-       tg.run("list", "...")
-       tg.grepStdout("x/build/gerrit", "missing expected x/build/gerrit")
-}
-
-func TestIssue11307(t *testing.T) {
-       // go get -u was not working except in checkout directory
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.parallel()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "github.com/rsc/go-get-issue-11307")
-       tg.run("get", "-u", "github.com/rsc/go-get-issue-11307") // was failing
-}
-
 func TestShadowingLogic(t *testing.T) {
        skipIfGccgo(t, "gccgo has no standard packages")
        tg := testgo(t)
@@ -2238,30 +2146,6 @@ func TestGoTestBuildsAnXtestContainingOnlyNonRunnableExamples(t *testing.T) {
        tg.grepStdout("File with non-runnable example was built.", "file with non-runnable example was not built")
 }
 
-func TestGoGetCustomDomainWildcard(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "-u", "rsc.io/pdf/...")
-       tg.wantExecutable(tg.path("bin/pdfpasswd"+exeSuffix), "did not build rsc/io/pdf/pdfpasswd")
-}
-
-func TestGoGetInternalWildcard(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       // used to fail with errors about internal packages
-       tg.run("get", "github.com/rsc/go-get-issue-11960/...")
-}
-
 func TestGoVetWithExternalTests(t *testing.T) {
        tg := testgo(t)
        defer tg.cleanup()
@@ -2322,19 +2206,6 @@ func TestVetWithOnlyCgoFiles(t *testing.T) {
        tg.run("vet", "p")
 }
 
-// Issue 9767, 19769.
-func TestGoGetDotSlashDownload(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.tempDir("src/rsc.io")
-       tg.setenv("GOPATH", tg.path("."))
-       tg.cd(tg.path("src/rsc.io"))
-       tg.run("get", "./pprof_mac_fix")
-}
-
 // Test that you cannot use a local import in a package
 // accessed by a non-local import (found in a GOPATH/GOROOT).
 // See golang.org/issue/17475.
@@ -2547,79 +2418,6 @@ func TestGoTestRaceInstallCgo(t *testing.T) {
        }
 }
 
-func TestGoGetUpdate(t *testing.T) {
-       // golang.org/issue/9224.
-       // The recursive updating was trying to walk to
-       // former dependencies, not current ones.
-
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-
-       rewind := func() {
-               tg.run("get", "github.com/rsc/go-get-issue-9224-cmd")
-               cmd := exec.Command("git", "reset", "--hard", "HEAD~")
-               cmd.Dir = tg.path("src/github.com/rsc/go-get-issue-9224-lib")
-               out, err := cmd.CombinedOutput()
-               if err != nil {
-                       t.Fatalf("git: %v\n%s", err, out)
-               }
-       }
-
-       rewind()
-       tg.run("get", "-u", "github.com/rsc/go-get-issue-9224-cmd")
-
-       // Again with -d -u.
-       rewind()
-       tg.run("get", "-d", "-u", "github.com/rsc/go-get-issue-9224-cmd")
-}
-
-// Issue #20512.
-func TestGoGetRace(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-       if !canRace {
-               t.Skip("skipping because race detector not supported")
-       }
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "-race", "github.com/rsc/go-get-issue-9224-cmd")
-}
-
-func TestGoGetDomainRoot(t *testing.T) {
-       // golang.org/issue/9357.
-       // go get foo.io (not foo.io/subdir) was not working consistently.
-
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-
-       // go-get-issue-9357.appspot.com is running
-       // the code at github.com/rsc/go-get-issue-9357,
-       // a trivial Go on App Engine app that serves a
-       // <meta> tag for the domain root.
-       tg.run("get", "-d", "go-get-issue-9357.appspot.com")
-       tg.run("get", "go-get-issue-9357.appspot.com")
-       tg.run("get", "-u", "go-get-issue-9357.appspot.com")
-
-       tg.must(robustio.RemoveAll(tg.path("src/go-get-issue-9357.appspot.com")))
-       tg.run("get", "go-get-issue-9357.appspot.com")
-
-       tg.must(robustio.RemoveAll(tg.path("src/go-get-issue-9357.appspot.com")))
-       tg.run("get", "-u", "go-get-issue-9357.appspot.com")
-}
-
 func TestGoInstallShadowedGOPATH(t *testing.T) {
        // golang.org/issue/3652.
        // go get foo.io (not foo.io/subdir) was not working consistently.
@@ -2825,18 +2623,6 @@ func TestParallelTest(t *testing.T) {
        tg.run("test", "-p=4", "p1", "p2", "p3", "p4")
 }
 
-// Issue 14444: go get -u .../ duplicate loads errors
-func TestGoGetUpdateAllDoesNotTryToLoadDuplicates(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       tg.run("get", "-u", ".../")
-       tg.grepStderrNot("duplicate loads of", "did not remove old packages from cache")
-}
-
 func TestBinaryOnlyPackages(t *testing.T) {
        tooSlow(t)
 
@@ -2933,36 +2719,6 @@ func TestGenerateUsesBuildContext(t *testing.T) {
        tg.grepStdout("darwin 386", "unexpected GOOS/GOARCH combination")
 }
 
-// Issue 14450: go get -u .../ tried to import not downloaded package
-func TestGoGetUpdateWithWildcard(t *testing.T) {
-       testenv.MustHaveExternalNetwork(t)
-       testenv.MustHaveExecPath(t, "git")
-
-       tg := testgo(t)
-       defer tg.cleanup()
-       tg.parallel()
-       tg.makeTempdir()
-       tg.setenv("GOPATH", tg.path("."))
-       const aPkgImportPath = "github.com/tmwh/go-get-issue-14450/a"
-       tg.run("get", aPkgImportPath)
-       tg.runFail("get", "-u", ".../")
-       tg.grepStderr("cannot find package.*d-dependency/e", "should have detected e missing")
-
-       // Even though get -u failed, the source for others should be downloaded.
-       var expectedPkgPaths = []string{
-               "src/github.com/tmwh/go-get-issue-14450/b",
-               "src/github.com/tmwh/go-get-issue-14450-b-dependency/c",
-               "src/github.com/tmwh/go-get-issue-14450-b-dependency/d",
-       }
-
-       for _, importPath := range expectedPkgPaths {
-               _, err := os.Stat(tg.path(importPath))
-               tg.must(err)
-       }
-       const notExpectedPkgPath = "src/github.com/tmwh/go-get-issue-14450-c-dependency/e"
-       tg.mustNotExist(tg.path(notExpectedPkgPath))
-}
-
 func TestGoEnv(t *testing.T) {
        tg := testgo(t)
        tg.parallel()
diff --git a/src/cmd/go/testdata/script/get_custom_domain_wildcard.txt b/src/cmd/go/testdata/script/get_custom_domain_wildcard.txt
new file mode 100644 (file)
index 0000000..743fbb3
--- /dev/null
@@ -0,0 +1,5 @@
+[!net] skip
+[!exec:git] skip
+
+go get -u rsc.io/pdf/...
+exists $GOPATH/bin/pdfpasswd$GOEXE
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/get_dash_t.txt b/src/cmd/go/testdata/script/get_dash_t.txt
new file mode 100644 (file)
index 0000000..be5c8dd
--- /dev/null
@@ -0,0 +1,8 @@
+# Tests issue 8181
+
+[!net] skip
+[!exec:git] skip
+
+go get -v -t github.com/rsc/go-get-issue-8181/a github.com/rsc/go-get-issue-8181/b
+go list ...
+stdout 'x/build/gerrit'
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/get_domain_root.txt b/src/cmd/go/testdata/script/get_domain_root.txt
new file mode 100644 (file)
index 0000000..580d1ca
--- /dev/null
@@ -0,0 +1,19 @@
+# Tests issue #9357
+# go get foo.io (not foo.io/subdir) was not working consistently.
+
+[!net] skip
+[!exec:git] skup
+
+# go-get-issue-9357.appspot.com is running
+# the code at github.com/rsc/go-get-issue-9357,
+# a trivial Go on App Engine app that serves a
+# <meta> tag for the domain root.
+go get -d go-get-issue-9357.appspot.com
+go get go-get-issue-9357.appspot.com
+go get -u go-get-issue-9357.appspot.com
+
+rm $GOPATH/src/go-get-issue-9357.appspot.com
+go get go-get-issue-9357.appspot.com
+
+rm $GOPATH/src/go-get-issue-9357.appspot.com
+go get -u go-get-issue-9357.appspot.com
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/get_dot_slash_download.txt b/src/cmd/go/testdata/script/get_dot_slash_download.txt
new file mode 100644 (file)
index 0000000..0396e1b
--- /dev/null
@@ -0,0 +1,9 @@
+[!net] skip
+[!exec:git] skip
+
+# Tests Issues #9797 and #19769
+
+mkdir $WORK/tmp/src/rsc.io
+env GOPATH=$WORK/tmp
+cd $WORK/tmp/src/rsc.io
+go get ./pprof_mac_fix
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/get_goroot.txt b/src/cmd/go/testdata/script/get_goroot.txt
new file mode 100644 (file)
index 0000000..49f1a17
--- /dev/null
@@ -0,0 +1,52 @@
+[!net] skip
+
+# Issue 4186. go get cannot be used to download packages to $GOROOT.
+# Test that without GOPATH set, go get should fail.
+
+# Fails because GOROOT=GOPATH
+env GOPATH=$WORK/tmp
+env GOROOT=$WORK/tmp
+! go get -d github.com/golang/example/hello
+stderr 'warning: GOPATH set to GOROOT'
+stderr '\$GOPATH must not be set to \$GOROOT'
+
+# Fails because GOROOT=GOPATH after cleaning.
+env GOPATH=$WORK/tmp/
+env GOROOT=$WORK/tmp
+! go get -d github.com/golang/example/hello
+stderr 'warning: GOPATH set to GOROOT'
+stderr '\$GOPATH must not be set to \$GOROOT'
+
+env GOPATH=$WORK/tmp
+env GOROOT=$WORK/tmp/
+! go get -d github.com/golang/example/hello
+stderr 'warning: GOPATH set to GOROOT'
+stderr '\$GOPATH must not be set to \$GOROOT'
+
+# Make a home directory
+mkdir $WORK/home/go
+
+# Fails because GOROOT=$HOME/go so default GOPATH unset.
+[windows] env USERPROFILE=$WORK/home
+[plan9] env home=$WORK/home
+[!windows] [!plan9] env HOME=$WORK/home
+env GOPATH=
+env GOROOT=$WORK/home/go
+! go get -d github.com/golang/example/hello
+stderr '\$GOPATH not set'
+
+[windows] env USERPROFILE=$WORK/home/
+[plan9] env home=$WORK/home/
+[!windows] [!plan9] env HOME=$WORK/home/
+env GOPATH=
+env GOROOT=$WORK/home/go
+! go get -d github.com/golang/example/hello
+stderr '\$GOPATH not set'
+
+[windows] env USERPROFILE=$WORK/home
+[plan9] env home=$WORK/home
+[!windows] [!plan9] env HOME=$WORK/home
+env GOPATH=
+env GOROOT=$WORK/home/go/
+! go get -d github.com/golang/example/hello
+stderr '\$GOPATH not set'
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/get_internal_wildcard.txt b/src/cmd/go/testdata/script/get_internal_wildcard.txt
new file mode 100644 (file)
index 0000000..82bb0d5
--- /dev/null
@@ -0,0 +1,5 @@
+[!net] skip
+[!exec:git] skip
+
+# This used to fail with errors about internal packages
+go get github.com/rsc/go-get-issue-11960/...
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/get_issue11307.txt b/src/cmd/go/testdata/script/get_issue11307.txt
new file mode 100644 (file)
index 0000000..da7704d
--- /dev/null
@@ -0,0 +1,8 @@
+# go get -u was not working except in checkout directory
+
+[!net] skip
+[!exec:git] skip
+
+env GOPATH=$WORK/tmp/gopath
+go get github.com/rsc/go-get-issue-11307
+go get -u github.com/rsc/go-get-issue-11307 # was failing
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/get_race.txt b/src/cmd/go/testdata/script/get_race.txt
new file mode 100644 (file)
index 0000000..8b34c95
--- /dev/null
@@ -0,0 +1,7 @@
+# Tests issue #20502
+
+[!net] skip
+[!exec:git] skip
+[!race] skip
+
+go get -race github.com/rsc/go-get-issue-9224-cmd
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/get_test_only.txt b/src/cmd/go/testdata/script/get_test_only.txt
new file mode 100644 (file)
index 0000000..7437c30
--- /dev/null
@@ -0,0 +1,5 @@
+[!net] skip
+[!exec:git] skip
+
+go get golang.org/x/tour/content...
+go get -t golang.org/x/tour/content...
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/get_update.txt b/src/cmd/go/testdata/script/get_update.txt
new file mode 100644 (file)
index 0000000..df889c4
--- /dev/null
@@ -0,0 +1,24 @@
+# Tests Issue #9224
+# The recursive updating was trying to walk to
+# former dependencies, not current ones.
+
+[!net] skip
+[!exec:git] skip
+
+# Rewind
+go get github.com/rsc/go-get-issue-9224-cmd
+cd $GOPATH/src/github.com/rsc/go-get-issue-9224-lib
+exec git reset --hard HEAD~
+cd $GOPATH/src
+
+# Run get
+go get -u 'github.com/rsc/go-get-issue-9224-cmd'
+
+# (Again with -d -u) Rewind
+go get github.com/rsc/go-get-issue-9224-cmd
+cd $GOPATH/src/github.com/rsc/go-get-issue-9224-lib
+exec git reset --hard HEAD~
+cd $GOPATH/src
+
+# (Again with -d -u) Run get
+go get -d -u 'github.com/rsc/go-get-issue-9224-cmd'
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/get_update_all.txt b/src/cmd/go/testdata/script/get_update_all.txt
new file mode 100644 (file)
index 0000000..1f2f5bf
--- /dev/null
@@ -0,0 +1,7 @@
+# Issue 14444: go get -u .../ duplicate loads errors
+# Check that go get update -u ... does not try to load duplicates
+
+[!net] skip
+
+go get -u .../
+! stderr 'duplicate loads of' # make sure old packages are removed from cache
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/get_update_wildcard.txt b/src/cmd/go/testdata/script/get_update_wildcard.txt
new file mode 100644 (file)
index 0000000..bfa47a2
--- /dev/null
@@ -0,0 +1,15 @@
+# Issue 14450: go get -u .../ tried to import not downloaded package
+
+[!net] skip
+[!exec:git] skip
+
+go get github.com/tmwh/go-get-issue-14450/a
+! go get -u .../
+stderr 'cannot find package.*d-dependency/e'
+
+# Even though get -u failed, the source for others should be downloaded.
+exists github.com/tmwh/go-get-issue-14450/b
+exists github.com/tmwh/go-get-issue-14450-b-dependency/c
+exists github.com/tmwh/go-get-issue-14450-b-dependency/d
+
+! exists github.com/tmwh/go-get-issue-14450-c-dependency/e
\ No newline at end of file