Skip to content

Commit b0bd77b

Browse files
authoredDec 23, 2022
Ensure go test coverprofile outputs to the expected location (#1105)
1 parent 49fab7a commit b0bd77b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
 

‎ginkgo/internal/run.go

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"os"
88
"os/exec"
9+
"path/filepath"
910
"regexp"
1011
"strings"
1112
"syscall"
@@ -63,6 +64,12 @@ func checkForNoTestsWarning(buf *bytes.Buffer) bool {
6364
}
6465

6566
func runGoTest(suite TestSuite, cliConfig types.CLIConfig, goFlagsConfig types.GoFlagsConfig) TestSuite {
67+
// As we run the go test from the suite directory, make sure the cover profile is absolute
68+
// and placed into the expected output directory when one is configured.
69+
if goFlagsConfig.Cover && !filepath.IsAbs(goFlagsConfig.CoverProfile) {
70+
goFlagsConfig.CoverProfile = AbsPathForGeneratedAsset(goFlagsConfig.CoverProfile, suite, cliConfig, 0)
71+
}
72+
6673
args, err := types.GenerateGoTestRunArgs(goFlagsConfig)
6774
command.AbortIfError("Failed to generate test run arguments", err)
6875
cmd, buf := buildAndStartCommand(suite, args, true)

0 commit comments

Comments
 (0)