1
0
mirror of https://github.com/golang/go synced 2024-11-18 21:34:46 -07:00

cmd/go: use -o option of cover tool

Separates correct from erroneous output so errors running the tool will appear
in the log.

R=rsc
CC=golang-dev
https://golang.org/cl/10191043
This commit is contained in:
Rob Pike 2013-06-11 20:47:35 -07:00
parent ae5e791ed2
commit bc7e26621e

View File

@ -1110,14 +1110,15 @@ func (b *builder) copyFile(a *action, dst, src string, perm os.FileMode) error {
} }
// cover runs, in effect, // cover runs, in effect,
// go tool cover -mode=b.coverMode -count="count" -pos="pos" src.go >dst.go // go tool cover -mode=b.coverMode -count="count" -pos="pos" -o dst.go src.go
func (b *builder) cover(a *action, dst, src string, perm os.FileMode, count, pos string) error { func (b *builder) cover(a *action, dst, src string, perm os.FileMode, count, pos string) error {
out, err := b.runOut(a.objdir, "cover "+a.p.ImportPath, nil, tool("cover"), "-mode="+a.p.coverMode, "-count="+count, "-pos="+pos, src) return b.run(a.objdir, "cover "+a.p.ImportPath, nil,
if err != nil { tool("cover"),
return err "-mode", a.p.coverMode,
} "-count", count,
// Output is processed source code. Write it to destination. "-pos", pos,
return ioutil.WriteFile(dst, out, perm) "-o", dst,
src)
} }
var objectMagic = [][]byte{ var objectMagic = [][]byte{