Skip to content

Commit

Permalink
capture cover output and check it for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersonQ committed Jul 25, 2023
1 parent 7a985ab commit be71233
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,17 @@ func GoTest(ctx context.Context, params GoTestArgs) error {
if params.CoverageProfileFile != "" {
htmlCoverReport = strings.TrimSuffix(params.CoverageProfileFile,
filepath.Ext(params.CoverageProfileFile)) + ".html"
coverToHTML := sh.RunCmd("go", "tool", "cover",
coverToHTML := sh.OutCmd("go", "tool", "cover",
"-html="+params.CoverageProfileFile,
"-o", htmlCoverReport)

if err = coverToHTML(); err != nil {
if out, err := coverToHTML(); err != nil {
// ignore known issue, see https://github.com/elastic/beats/issues/35927
if !(strings.Contains(err.Error(), "can't read") &&
strings.Contains(err.Error(), "filebeat/input/syslog/format_check.rl")) {
if !(strings.Contains(out, "can't read") &&
strings.Contains(out, "filebeat/input/syslog/format_check.rl")) {
return fmt.Errorf("failed to write HTML code coverage report: %w", err)
}

Check failure on line 322 in dev-tools/mage/gotest.go

View workflow job for this annotation

GitHub Actions / lint (linux)

File is not `goimports`-ed with -local github.com/elastic (goimports)
fmt.Println(">> go test: go tool cover returned an error, but " +
"will ignore it, see https://github.com/elastic/beats/issues/35927")
fmt.Println(">> go test: the error was:")
Expand Down

0 comments on commit be71233

Please sign in to comment.