@@ -196,8 +196,11 @@ func (r *Runner) parseTestResults(filePaths []string) ([]reports.TestResult, err
196196 expectedRuns = r .RunCount
197197 )
198198
199+ runNumber := 0
199200 // Process each file
200201 for _ , filePath := range filePaths {
202+ runNumber ++
203+ runID := fmt .Sprintf ("run%d" , runNumber )
201204 file , err := os .Open (filePath )
202205 if err != nil {
203206 return nil , fmt .Errorf ("failed to open test output file: %w" , err )
@@ -243,7 +246,8 @@ func (r *Runner) parseTestResults(filePaths []string) ([]reports.TestResult, err
243246 TestName : entryLine .Test ,
244247 TestPackage : entryLine .Package ,
245248 PassRatio : 0 ,
246- Outputs : []string {},
249+ PassedOutputs : make (map [string ][]string ),
250+ FailedOutputs : make (map [string ][]string ),
247251 PackageOutputs : []string {},
248252 }
249253 }
@@ -264,13 +268,27 @@ func (r *Runner) parseTestResults(filePaths []string) ([]reports.TestResult, err
264268 detectedEntries = append (detectedEntries , entryLine )
265269 raceDetectionMode = true
266270 continue // Don't process this entry further
271+ } else if entryLine .Test != "" && entryLine .Action == "output" {
272+ // Collect outputs regardless of pass or fail
273+ if result .Outputs == nil {
274+ result .Outputs = make (map [string ][]string )
275+ }
276+ result .Outputs [runID ] = append (result .Outputs [runID ], entryLine .Output )
267277 } else if entryLine .Test == "" {
268278 if _ , exists := packageLevelOutputs [entryLine .Package ]; ! exists {
269279 packageLevelOutputs [entryLine .Package ] = []string {}
270280 }
271281 packageLevelOutputs [entryLine .Package ] = append (packageLevelOutputs [entryLine .Package ], entryLine .Output )
272- } else if entryLine .Test != "" {
273- result .Outputs = append (result .Outputs , entryLine .Output )
282+ } else {
283+ // Collect outputs per run, per test action
284+ switch entryLine .Action {
285+ case "pass" :
286+ result .PassedOutputs [runID ] = append (result .PassedOutputs [runID ], entryLine .Output )
287+ case "fail" :
288+ result .FailedOutputs [runID ] = append (result .FailedOutputs [runID ], entryLine .Output )
289+ default :
290+ // Handle other actions if necessary
291+ }
274292 }
275293 }
276294
@@ -290,7 +308,8 @@ func (r *Runner) parseTestResults(filePaths []string) ([]reports.TestResult, err
290308 TestName : panicTest ,
291309 TestPackage : entryLine .Package ,
292310 PassRatio : 0 ,
293- Outputs : []string {},
311+ PassedOutputs : make (map [string ][]string ),
312+ FailedOutputs : make (map [string ][]string ),
294313 PackageOutputs : []string {},
295314 }
296315 testDetails [panicTestKey ] = result
@@ -306,7 +325,8 @@ func (r *Runner) parseTestResults(filePaths []string) ([]reports.TestResult, err
306325 if entry .Test == "" {
307326 result .PackageOutputs = append (result .PackageOutputs , entry .Output )
308327 } else {
309- result .Outputs = append (result .Outputs , entry .Output )
328+ runID := fmt .Sprintf ("run%d" , runNumber )
329+ result .FailedOutputs [runID ] = append (result .FailedOutputs [runID ], entry .Output )
310330 }
311331 }
312332 } else if raceDetectionMode {
@@ -324,7 +344,8 @@ func (r *Runner) parseTestResults(filePaths []string) ([]reports.TestResult, err
324344 TestName : raceTest ,
325345 TestPackage : entryLine .Package ,
326346 PassRatio : 0 ,
327- Outputs : []string {},
347+ PassedOutputs : make (map [string ][]string ),
348+ FailedOutputs : make (map [string ][]string ),
328349 PackageOutputs : []string {},
329350 }
330351 testDetails [raceTestKey ] = result
@@ -339,7 +360,8 @@ func (r *Runner) parseTestResults(filePaths []string) ([]reports.TestResult, err
339360 if entry .Test == "" {
340361 result .PackageOutputs = append (result .PackageOutputs , entry .Output )
341362 } else {
342- result .Outputs = append (result .Outputs , entry .Output )
363+ runID := fmt .Sprintf ("run%d" , runNumber )
364+ result .FailedOutputs [runID ] = append (result .FailedOutputs [runID ], entry .Output )
343365 }
344366 }
345367 }
@@ -359,10 +381,14 @@ func (r *Runner) parseTestResults(filePaths []string) ([]reports.TestResult, err
359381 }
360382 result .Durations = append (result .Durations , duration )
361383 result .Successes ++
362- if r .OmitOutputsOnSuccess {
363- // Clear outputs for passing tests
364- result .Outputs = nil
384+
385+ // Move outputs to PassedOutputs
386+ if result .PassedOutputs == nil {
387+ result .PassedOutputs = make (map [string ][]string )
365388 }
389+ result .PassedOutputs [runID ] = result .Outputs [runID ]
390+ // Clear temporary outputs
391+ delete (result .Outputs , runID )
366392 }
367393 case "fail" :
368394 if entryLine .Test != "" {
@@ -372,12 +398,18 @@ func (r *Runner) parseTestResults(filePaths []string) ([]reports.TestResult, err
372398 }
373399 result .Durations = append (result .Durations , duration )
374400 result .Failures ++
401+
402+ // Move outputs to FailedOutputs
403+ if result .FailedOutputs == nil {
404+ result .FailedOutputs = make (map [string ][]string )
405+ }
406+ result .FailedOutputs [runID ] = result .Outputs [runID ]
407+ // Clear temporary outputs
408+ delete (result .Outputs , runID )
375409 }
376- case "skip" :
377- if entryLine .Test != "" {
378- result .Skipped = true
379- result .Skips ++
380- }
410+ case "output" :
411+ // Handled above when entryLine.Test is not empty
412+ // ...existing code for other actions...
381413 }
382414 if entryLine .Test != "" {
383415 result .Runs = result .Successes + result .Failures
@@ -412,7 +444,14 @@ func (r *Runner) parseTestResults(filePaths []string) ([]reports.TestResult, err
412444 if subTestResult , exists := testDetails [subTestKey ]; exists {
413445 if subTestResult .Failures > 0 {
414446 subTestResult .Panic = true
415- subTestResult .Outputs = append (subTestResult .Outputs , "Panic in parent test" )
447+ // Initialize Outputs map if nil
448+ if subTestResult .FailedOutputs == nil {
449+ subTestResult .FailedOutputs = make (map [string ][]string )
450+ }
451+ // Add the message to each run's output
452+ for runID := range subTestResult .FailedOutputs {
453+ subTestResult .FailedOutputs [runID ] = append (subTestResult .FailedOutputs [runID ], "Panic in parent test" )
454+ }
416455 }
417456 } else {
418457 log .Printf ("WARN: expected to find subtest '%s' inside parent test '%s', but not found\n " , subTestKey , parentTestKey )
0 commit comments