tg.makeTempdir()
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
- tg.run("test", "-coverprofile="+filepath.Join(tg.tempdir, "cover.out"), "coverasm")
+ tg.run("test", "-outputdir="+tg.tempdir, "-coverprofile=cover.out", "coverasm")
tg.run("tool", "cover", "-func="+filepath.Join(tg.tempdir, "cover.out"))
tg.grepStdout(`\tg\t*100.0%`, "did not find g 100% covered")
tg.grepStdoutNot(`\tf\t*[0-9]`, "reported coverage for assembly function f")
"fmt"
"io"
"os"
+ "path/filepath"
"sync"
)
if testCoverProfile == "" {
return
}
+ if !filepath.IsAbs(testCoverProfile) && testOutputDir != "" {
+ testCoverProfile = filepath.Join(testOutputDir, testCoverProfile)
+ }
// No mutex - caller's responsibility to call with no racing goroutines.
f, err := os.Create(testCoverProfile)
testCoverPaths []string // -coverpkg flag
testCoverPkgs []*load.Package // -coverpkg flag
testCoverProfile string // -coverprofile flag
+ testOutputDir string // -outputdir flag
testO string // -o flag
testProfile string // profiling flag that limits test to one package
testNeedBinary bool // profile needs to keep binary around
// go test -x math
func testFlags(args []string) (packageNames, passToTest []string) {
inPkg := false
- outputDir := ""
var explicitArgs []string
for i := 0; i < len(args); i++ {
if !strings.HasPrefix(args[i], "-") {
}
testCover = true
case "outputdir":
- outputDir = value
+ testOutputDir = value
case "vet":
testVetList = value
}
}
// Tell the test what directory we're running in, so it can write the profiles there.
- if testProfile != "" && outputDir == "" {
+ if testProfile != "" && testOutputDir == "" {
dir, err := os.Getwd()
if err != nil {
base.Fatalf("error from os.Getwd: %s", err)