mirror of
https://github.com/golang/go
synced 2024-11-22 03:54:39 -07:00
cmd/go: clean test directories as they complete
A go build currently generates around 400MB of test output prior to cleaning up. With this change we use a maximum of ~15MB. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5588044
This commit is contained in:
parent
28397befab
commit
6f428f0979
@ -442,9 +442,14 @@ func (b *builder) test(p *Package) (buildAction, runAction, printAction *action,
|
||||
p: p,
|
||||
ignoreFail: true,
|
||||
}
|
||||
cleanAction := &action{
|
||||
f: (*builder).cleanTest,
|
||||
deps: []*action{runAction},
|
||||
p: p,
|
||||
}
|
||||
printAction = &action{
|
||||
f: (*builder).printTest,
|
||||
deps: []*action{runAction},
|
||||
deps: []*action{cleanAction},
|
||||
p: p,
|
||||
}
|
||||
}
|
||||
@ -521,12 +526,22 @@ func (b *builder) runTest(a *action) error {
|
||||
} else {
|
||||
fmt.Fprintf(a.testOutput, "%s\n", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// cleanTest is the action for cleaning up after a test.
|
||||
func (b *builder) cleanTest(a *action) error {
|
||||
run := a.deps[0]
|
||||
testDir := filepath.Join(b.work, filepath.FromSlash(run.p.ImportPath+"/_test"))
|
||||
os.RemoveAll(testDir)
|
||||
return nil
|
||||
}
|
||||
|
||||
// printTest is the action for printing a test result.
|
||||
func (b *builder) printTest(a *action) error {
|
||||
run := a.deps[0]
|
||||
clean := a.deps[0]
|
||||
run := clean.deps[0]
|
||||
os.Stdout.Write(run.testOutput.Bytes())
|
||||
run.testOutput = nil
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user