Skip to content

Commit 6a2cd82

Browse files
committed
gopherage: write failure message instead of boolean
The <failure> element in JUnit is expected to contain a failure message. Writing "true" caused spyglass to show that string as failure message, which was confusing when looking at https://prow.k8s.io/?job=ci-kubernetes-coverage-unit results.
1 parent ae9036a commit 6a2cd82

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gopherage/pkg/cov/junit/xmlwriter.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type TestCase struct {
4343
ClassName string `xml:"class_name,attr"`
4444
Name string `xml:"name,attr"`
4545
Time string `xml:"time,attr"`
46-
Failure bool `xml:"failure,omitempty"`
46+
Failure string `xml:"failure,omitempty"`
4747
PropertyList Properties `xml:"properties"`
4848
}
4949

@@ -58,7 +58,6 @@ func (ts *Testsuite) addTestCase(coverageTargetName string, ratio, threshold flo
5858
ClassName: "go_coverage",
5959
Name: coverageTargetName,
6060
Time: "0",
61-
Failure: ratio < threshold,
6261
PropertyList: Properties{
6362
PropertyList: []Property{
6463
{
@@ -68,6 +67,9 @@ func (ts *Testsuite) addTestCase(coverageTargetName string, ratio, threshold flo
6867
},
6968
},
7069
}
70+
if ratio < threshold {
71+
testCase.Failure = fmt.Sprintf("code coverage of %.0f%% is below threshold of %.0f%%", 100*ratio, 100*threshold)
72+
}
7173
ts.Testcases = append(ts.Testcases, testCase)
7274
}
7375

0 commit comments

Comments
 (0)