Skip to content

Commit a9bb72f

Browse files
authored
Fix scorecard XUnit result schema (#5774)
Error and failure cases are currently reported incorrectly. Tools that consume the XUnit schema expect the result element to be named with its type and also have an attribute with its type. This commit changes the output for the result from the incorrect format: `<result type="failure">..></result>` to the expected format: `<failure type="failure">...</failure>`. Signed-off-by: Ryan King <[email protected]>
1 parent 659df85 commit a9bb72f

File tree

1 file changed

+5
-5
lines changed
  • internal/cmd/operator-sdk/scorecard/xunit

1 file changed

+5
-5
lines changed

internal/cmd/operator-sdk/scorecard/xunit/xunit.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (ts *TestSuite) AddSuccess(name string, time time.Time, logs string) {
7272
func (ts *TestSuite) AddFailure(name string, time time.Time, logs, msg string) {
7373
ts.Failures++
7474
ts.addTest(name, time, logs, &Result{
75-
Name: xml.Name{Local: "failure"},
75+
XMLName: xml.Name{Local: "failure"},
7676
Type: "failure",
7777
Message: msg,
7878
})
@@ -82,7 +82,7 @@ func (ts *TestSuite) AddFailure(name string, time time.Time, logs, msg string) {
8282
func (ts *TestSuite) AddError(name string, time time.Time, logs, msg string) {
8383
ts.Errors++
8484
ts.addTest(name, time, logs, &Result{
85-
Name: xml.Name{Local: "error"},
85+
XMLName: xml.Name{Local: "error"},
8686
Type: "error",
8787
Message: msg,
8888
})
@@ -108,7 +108,7 @@ type TestCase struct {
108108

109109
// Result represents the final state of the test case.
110110
type Result struct {
111-
Name xml.Name
112-
Type string
113-
Message string
111+
XMLName xml.Name
112+
Type string `xml:"type,attr"`
113+
Message string `xml:",innerxml"`
114114
}

0 commit comments

Comments
 (0)