Skip to content

Commit

Permalink
Print error text in <failure> tag content for more readable junit rep…
Browse files Browse the repository at this point in the history
…ort (golangci#2460)
  • Loading branch information
byrnedo authored and SeigeC committed Apr 4, 2023
1 parent c256d22 commit 4849a55
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/printers/junitxml.go
Expand Up @@ -3,6 +3,7 @@ package printers
import (
"context"
"encoding/xml"
"fmt"
"io"
"strings"

Expand Down Expand Up @@ -31,6 +32,7 @@ type testCaseXML struct {

type failureXML struct {
Message string `xml:"message,attr"`
Type string `xml:"type,attr"`
Content string `xml:",cdata"`
}

Expand All @@ -57,8 +59,10 @@ func (p JunitXML) Print(ctx context.Context, issues []result.Issue) error {
Name: i.FromLinter,
ClassName: i.Pos.String(),
Failure: failureXML{
Message: i.Text,
Content: strings.Join(i.SourceLines, "\n"),
Type: i.Severity,
Message: i.Pos.String() + ": " + i.Text,
Content: fmt.Sprintf("%s: %s\nCategory: %s\nFile: %s\nLine: %d\nDetails: %s",
i.Severity, i.Text, i.FromLinter, i.Pos.Filename, i.Pos.Line, strings.Join(i.SourceLines, "\n")),
},
}

Expand Down

0 comments on commit 4849a55

Please sign in to comment.