diff options
author | Russ Cox <rsc@golang.org> | 2017-10-27 13:45:50 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2017-10-31 13:20:41 +0000 |
commit | 2e2047a07fea81f65170eca9562a649ba2f5b11d (patch) | |
tree | 0c1c86f3b47c0838dfa2fd9e24b512f89a93728d /src/runtime/race | |
parent | 94471f6324d25e2562c9125aeeeb2af6f2a51fd4 (diff) | |
download | go-2e2047a07fea81f65170eca9562a649ba2f5b11d.tar.gz go-2e2047a07fea81f65170eca9562a649ba2f5b11d.zip |
runtime/race: install alternate packages to temp dir
The content-based staleness code means that
go run -gcflags=-l helloworld.go
recompiles all of helloworld.go's dependencies with -gcflags=-l,
whereas before it would have assumed installed packages were
up-to-date. In this test, that means every race iteration rebuilds
the runtime and maybe a few other packages. Instead, install them
to a temporary location for reuse.
This speeds the test from 17s to 9s on my MacBook Pro.
Change-Id: Ied136ce72650261083bb19cc7dee38dac0ad05ca
Reviewed-on: https://go-review.googlesource.com/73992
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/race')
-rw-r--r-- | src/runtime/race/output_test.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/runtime/race/output_test.go b/src/runtime/race/output_test.go index 13dfc33b47..f5b6fea43e 100644 --- a/src/runtime/race/output_test.go +++ b/src/runtime/race/output_test.go @@ -19,6 +19,16 @@ import ( ) func TestOutput(t *testing.T) { + pkgdir, err := ioutil.TempDir("", "go-build-race-output") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(pkgdir) + out, err := exec.Command(testenv.GoToolPath(t), "install", "-race", "-pkgdir="+pkgdir, "-gcflags=-l", "testing").CombinedOutput() + if err != nil { + t.Fatalf("go install -race: %v\n%s", err, out) + } + for _, test := range tests { if test.goos != "" && test.goos != runtime.GOOS { t.Logf("test %v runs only on %v, skipping: ", test.name, test.goos) @@ -47,7 +57,7 @@ func TestOutput(t *testing.T) { t.Fatalf("failed to close file: %v", err) } // Pass -l to the compiler to test stack traces. - cmd := exec.Command(testenv.GoToolPath(t), test.run, "-race", "-gcflags=-l", src) + cmd := exec.Command(testenv.GoToolPath(t), test.run, "-race", "-pkgdir="+pkgdir, "-gcflags=-l", src) // GODEBUG spoils program output, GOMAXPROCS makes it flaky. for _, env := range os.Environ() { if strings.HasPrefix(env, "GODEBUG=") || |