@@ -223,21 +223,26 @@ func testReport(input, reportFile, packageName string, t *testing.T) {
223
223
func modifyForBackwardsCompat (testsuites junit.Testsuites ) junit.Testsuites {
224
224
testsuites .XMLName .Local = ""
225
225
for i , suite := range testsuites .Suites {
226
- if covIdx , covProp := getProperty ("coverage.statements.pct" , suite .Properties ); covIdx > - 1 {
227
- pct , _ := strconv .ParseFloat (covProp .Value , 64 )
228
- testsuites .Suites [i ].Properties [covIdx ].Value = fmt .Sprintf ("%.2f" , pct )
229
- }
230
- testsuites .Suites [i ].Properties = dropProperty ("go.version" , suite .Properties )
231
-
232
226
for j := range suite .Testcases {
233
227
testsuites .Suites [i ].Testcases [j ].Classname = suite .Name
234
228
}
229
+
230
+ if suite .Properties != nil {
231
+ if covIdx , covProp := getProperty ("coverage.statements.pct" , * suite .Properties ); covIdx > - 1 {
232
+ pct , _ := strconv .ParseFloat (covProp .Value , 64 )
233
+ (* testsuites .Suites [i ].Properties )[covIdx ].Value = fmt .Sprintf ("%.2f" , pct )
234
+ }
235
+ testsuites .Suites [i ].Properties = dropProperty ("go.version" , suite .Properties )
236
+ }
235
237
}
236
238
return testsuites
237
239
}
238
240
239
241
func dropNewProperties (testsuites junit.Testsuites ) junit.Testsuites {
240
242
for i , suite := range testsuites .Suites {
243
+ if suite .Properties == nil {
244
+ continue
245
+ }
241
246
ps := suite .Properties
242
247
ps = dropProperty ("goos" , ps )
243
248
ps = dropProperty ("goarch" , ps )
@@ -247,14 +252,20 @@ func dropNewProperties(testsuites junit.Testsuites) junit.Testsuites {
247
252
return testsuites
248
253
}
249
254
250
- func dropProperty (name string , properties []junit.Property ) []junit.Property {
255
+ func dropProperty (name string , properties * []junit.Property ) * []junit.Property {
256
+ if properties == nil {
257
+ return nil
258
+ }
251
259
var props []junit.Property
252
- for _ , prop := range properties {
260
+ for _ , prop := range * properties {
253
261
if prop .Name != name {
254
262
props = append (props , prop )
255
263
}
256
264
}
257
- return props
265
+ if len (props ) == 0 {
266
+ return nil
267
+ }
268
+ return & props
258
269
}
259
270
260
271
func getProperty (name string , properties []junit.Property ) (int , junit.Property ) {
0 commit comments