]> Cypherpunks.ru repositories - gostls13.git/commitdiff
internal/testenv: remove SetModVendor
authorBryan C. Mills <bcmills@google.com>
Fri, 8 Mar 2019 18:26:04 +0000 (13:26 -0500)
committerBryan C. Mills <bcmills@google.com>
Fri, 8 Mar 2019 23:40:24 +0000 (23:40 +0000)
It turns out not to be necessary. Russ expressed a preference for
avoiding module fetches over making 'go mod tidy' work within std and
cmd right away, so for now we will make the loader use the vendor
directory for the standard library even if '-mod=vendor' is not set
explicitly.

Updates #30228

Change-Id: Idf7208e63da8cb7bfe281b93ec21b61d40334947
Reviewed-on: https://go-review.googlesource.com/c/go/+/166357
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
17 files changed:
src/cmd/addr2line/addr2line_test.go
src/cmd/compile/internal/gc/scope_test.go
src/cmd/cover/cover_test.go
src/cmd/internal/obj/x86/obj6_test.go
src/cmd/link/internal/ld/ld_test.go
src/cmd/link/link_test.go
src/cmd/nm/nm_test.go
src/cmd/objdump/objdump_test.go
src/cmd/vet/all/main.go
src/cmd/vet/vet_test.go
src/crypto/x509/x509_test.go
src/debug/gosym/pclntab_test.go
src/go/importer/importer_test.go
src/go/internal/srcimporter/srcimporter_test.go
src/internal/testenv/testenv.go
src/runtime/crash_test.go
src/runtime/pprof/proto_test.go

index 183a22f8f378ff188c4646c0fc237ef0d5315118..22bf1379bb72147c6ccbf72603e4fc8654356478 100644 (file)
@@ -115,5 +115,3 @@ func TestAddr2Line(t *testing.T) {
        testAddr2Line(t, exepath, syms[symName])
        testAddr2Line(t, exepath, "0x"+syms[symName])
 }
-
-func init() { testenv.SetModVendor() }
index e4861c686cdf4e1a67f57c809f0b5141f0bb34bc..e327dc02af2df236e93d5c3eafe54aff21b10ac1 100644 (file)
@@ -202,8 +202,6 @@ var testfile = []testline{
 
 const detailOutput = false
 
-func init() { testenv.SetModVendor() }
-
 // Compiles testfile checks that the description of lexical blocks emitted
 // by the linker in debug_info, for each function in the main package,
 // corresponds to what we expect it to be.
index d7e6ca99b7fd63af3b7ee26cc2e17e89ac9855a0..f002442b638fb758edb5beaf23c37192a297ff02 100644 (file)
@@ -77,8 +77,6 @@ var debug = flag.Bool("debug", false, "keep rewritten files for debugging")
 // We use TestMain to set up a temporary directory and remove it when
 // the tests are done.
 func TestMain(m *testing.M) {
-       testenv.SetModVendor()
-
        dir, err := ioutil.TempDir("", "gotestcover")
        if err != nil {
                fmt.Fprintln(os.Stderr, err)
index 2b1a729c8fcfc89d9e33d446147ebd15e08ec145..c5399744f2d18761e4a03af33018d6b715051fca 100644 (file)
@@ -134,8 +134,6 @@ func parseOutput(t *testing.T, td *ParsedTestData, asmout []byte) {
        }
 }
 
-func init() { testenv.SetModVendor() }
-
 func TestDynlink(t *testing.T) {
        testenv.MustHaveGoBuild(t)
 
index 219b2a63cacc060e6df9ae88483e4cd0c4ff2781..081642931652bafe9a34750acfd8677cd2108445 100644 (file)
@@ -13,8 +13,6 @@ import (
        "testing"
 )
 
-func init() { testenv.SetModVendor() }
-
 func TestUndefinedRelocErrors(t *testing.T) {
        t.Parallel()
        testenv.MustHaveGoBuild(t)
index 5043a778ca9edfcac8b3db1f0c8104a07a4265cb..5200c3a6f084ca4f7a320eeb6ccb452db01de191 100644 (file)
@@ -38,8 +38,6 @@ func TestLargeSymName(t *testing.T) {
        _ = AuthorPaidByTheColumnInch
 }
 
-func init() { testenv.SetModVendor() }
-
 func TestIssue21703(t *testing.T) {
        t.Parallel()
 
index 82f4235510ecf251466f32c9deef30a0048ddd74..8176ddd7f458706065e33e910dd05860695f602a 100644 (file)
@@ -30,8 +30,6 @@ func testMain(m *testing.M) int {
                return 0
        }
 
-       testenv.SetModVendor()
-
        tmpDir, err := ioutil.TempDir("", "TestNM")
        if err != nil {
                fmt.Println("TempDir failed:", err)
index 7c874e853b92b459fce7d9247908f16e1099c50d..be9fe5274a18c0fd3db149cc1705730da584a6e4 100644 (file)
@@ -24,7 +24,6 @@ func TestMain(m *testing.M) {
        if !testenv.HasGoBuild() {
                return
        }
-       testenv.SetModVendor()
 
        var exitcode int
        if err := buildObjdump(); err == nil {
index 018eba4d6ec2073730f360ab3c417a80e040dd30..6e4a4e297eb89088ed137c75ebdce3d6821513da 100644 (file)
@@ -44,7 +44,6 @@ func main() {
        log.SetPrefix("vet/all: ")
        log.SetFlags(log.Lshortfile)
 
-       testenv.SetModVendor()
        var err error
        cmdGoPath, err = testenv.GoTool()
        if err != nil {
index 62c28fb9a21ccce7ab910b21a8db59bb5a0fed9b..5d8139d977b81393c0d7d8db8e269ef219f27509 100644 (file)
@@ -32,8 +32,6 @@ func TestMain(m *testing.M) {
 }
 
 func testMain(m *testing.M) int {
-       testenv.SetModVendor()
-
        dir, err := ioutil.TempDir("", "vet_test")
        if err != nil {
                fmt.Fprintln(os.Stderr, err)
index fbcdb7b58e75afb71a6751848e48f8fcd047650c..f5851f1f11b79fe03dbb8e5e038e2a3fd6f05d83 100644 (file)
@@ -1146,8 +1146,6 @@ func TestParsePEMCRL(t *testing.T) {
        // Can't check the signature here without a package cycle.
 }
 
-func init() { testenv.SetModVendor() }
-
 func TestImports(t *testing.T) {
        testenv.MustHaveGoRun(t)
 
index c67fb66f0d843caf102ff6d35da996ffa6a66bce..d21f0e24a8324030d4297d3b7a6697807bb20468 100644 (file)
@@ -21,8 +21,6 @@ var (
        pclinetestBinary string
 )
 
-func init() { testenv.SetModVendor() }
-
 func dotest(t *testing.T) {
        testenv.MustHaveGoBuild(t)
        // For now, only works on amd64 platforms.
index 2887ec6ea5b46b625ba166ff1b215ce31f22b32a..ff6e12c0da5233a5d340058e353a3768273a8722 100644 (file)
@@ -16,8 +16,6 @@ import (
        "testing"
 )
 
-func init() { testenv.SetModVendor() }
-
 func TestForCompiler(t *testing.T) {
        testenv.MustHaveGoBuild(t)
 
index 06472447a635dc88f5fd83440e8761546dd5e2d3..b84672610c6f8be8875062192fcb11b8d64c505e 100644 (file)
@@ -18,8 +18,6 @@ import (
        "time"
 )
 
-func init() { testenv.SetModVendor() }
-
 const maxTime = 2 * time.Second
 
 var importer = New(&build.Default, token.NewFileSet(), make(map[string]*types.Package))
index 72e4d803cb0ba9062da609e340e0ced5dc9260c3..8f69fe0da5fbda3180502907fab9f11c47f18e6f 100644 (file)
@@ -19,7 +19,6 @@ import (
        "runtime"
        "strconv"
        "strings"
-       "sync"
        "testing"
 )
 
@@ -78,31 +77,6 @@ func MustHaveGoRun(t testing.TB) {
        }
 }
 
-var modVendorOnce sync.Once
-
-// SetModVendor adds the "-mod=vendor" flag to the GOFLAGS environment variable.
-// This allows tests whose working directories are within the cmd and std
-// modules to run ``go'' commands without accessing the network to load
-// dependencies modules.
-//
-// SetModVendor must be called before any test may read the GOFLAGS environment
-// variable.
-//
-// TODO(golang.org/issue/30240): If we load go.mod files from vendor/
-// automatically, this will probably no longer be necessary.
-func SetModVendor() {
-       modVendorOnce.Do(func() {
-               var goflags []string
-               for _, f := range strings.Fields(os.Getenv("GOFLAGS")) {
-                       if !strings.HasPrefix(f, "-mod=") && !strings.HasPrefix(f, "--mod=") {
-                               goflags = append(goflags, f)
-                       }
-               }
-               goflags = append(goflags, "-mod=vendor")
-               os.Setenv("GOFLAGS", strings.Join(goflags, " "))
-       })
-}
-
 // GoToolPath reports the path to the Go tool.
 // It is a convenience wrapper around GoTool.
 // If the tool is unavailable GoToolPath calls t.Skip.
index 3a27b269a126919c0b1cc719f84accb5c7bcad63..03ebf022a6ef8d02aa94e4c9ff3be219f88090f5 100644 (file)
@@ -25,8 +25,6 @@ import (
 var toRemove []string
 
 func TestMain(m *testing.M) {
-       testenv.SetModVendor()
-
        status := m.Run()
        for _, file := range toRemove {
                os.RemoveAll(file)
index a276d81c491234f7b9ab95af1cbabe04bb3d5193..4452d5123158e5c40af264536d92a21624000ddc 100644 (file)
@@ -301,8 +301,6 @@ func TestProcSelfMaps(t *testing.T) {
        })
 }
 
-func init() { testenv.SetModVendor() }
-
 // TestMapping checkes the mapping section of CPU profiles
 // has the HasFunctions field set correctly. If all PCs included
 // in the samples are successfully symbolized, the corresponding