tg.run("build", "-o", tg.path("a.exe"), "a")
tg.run("test", "a")
}
+
+// Issue 23150.
+func TestCpuprofileTwice(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.parallel()
+ tg.tempFile("prof/src/x/x_test.go", `
+ package x_test
+ import (
+ "testing"
+ "time"
+ )
+ func TestSleep(t *testing.T) { time.Sleep(10 * time.Millisecond) }`)
+ tg.setenv("GOPATH", tg.path("prof"))
+ bin := tg.path("x.test")
+ out := tg.path("cpu.out")
+ tg.run("test", "-o="+bin, "-cpuprofile="+out, "x")
+ tg.must(os.Remove(out))
+ tg.run("test", "-o="+bin, "-cpuprofile="+out, "x")
+ tg.mustExist(out)
+}
if !c.disableCache && len(execCmd) == 0 {
testlogArg = []string{"-test.testlogfile=" + a.Objdir + "testlog.txt"}
}
- args := str.StringList(execCmd, a.Deps[0].Target, testlogArg, testArgs)
+ args := str.StringList(execCmd, a.Deps[0].BuiltTarget(), testlogArg, testArgs)
if testCoverProfile != "" {
// Write coverage to temporary profile, for merging later.
// BuildID returns a's build ID.
func (a *Action) BuildID() string { return a.buildID }
+// BuiltTarget returns the actual file that was built. This differs
+// from Target when the result was cached.
+func (a *Action) BuiltTarget() string { return a.built }
+
// An actionQueue is a priority queue of actions.
type actionQueue []*Action