diff options
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/go/internal/verylongtest/go_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/cmd/go/internal/verylongtest/go_test.go b/src/cmd/go/internal/verylongtest/go_test.go index eae8b85a45..8a2acf3690 100644 --- a/src/cmd/go/internal/verylongtest/go_test.go +++ b/src/cmd/go/internal/verylongtest/go_test.go @@ -6,6 +6,8 @@ package verylongtest import ( "bytes" + "flag" + "fmt" "internal/testenv" "os" "os/exec" @@ -13,6 +15,25 @@ import ( "testing" ) +func TestMain(m *testing.M) { + flag.Parse() + if testing.Short() { + return + } + + tmpdir, err := os.MkdirTemp("", "verylongtest") + if err != nil { + fmt.Fprintf(os.Stderr, "failed to create temp gocache: %v\n", err) + os.Exit(1) + } + os.Setenv("GOCACHE", tmpdir) + + code := m.Run() + + os.RemoveAll(tmpdir) + os.Exit(code) +} + // Regression test for golang.org/issue/34499: version command should not crash // when executed in a deleted directory on Linux. func TestExecInDeletedDir(t *testing.T) { |
