mirror of
https://github.com/golang/go
synced 2024-11-23 16:30:06 -07:00
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>
This commit is contained in:
parent
94471f6324
commit
2e2047a07f
@ -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=") ||
|
||||
|
Loading…
Reference in New Issue
Block a user