@@ -483,12 +483,28 @@ func avgDuration(durations []time.Duration) time.Duration {
483483// sortTestResults sorts results by TestPackage, TestName, and PassRatio for consistent comparison and pretty printing
484484func sortTestResults (results []TestResult ) {
485485 sort .Slice (results , func (i , j int ) bool {
486+ // Compare TestPackage first
486487 if results [i ].TestPackage != results [j ].TestPackage {
487488 return results [i ].TestPackage < results [j ].TestPackage
488489 }
489- if results [i ].TestName != results [j ].TestName {
490- return results [i ].TestName < results [j ].TestName
490+
491+ // Split TestName into components for hierarchical comparison
492+ iParts := strings .Split (results [i ].TestName , "/" )
493+ jParts := strings .Split (results [j ].TestName , "/" )
494+
495+ // Compare each part of the TestName hierarchically
496+ for k := 0 ; k < len (iParts ) && k < len (jParts ); k ++ {
497+ if iParts [k ] != jParts [k ] {
498+ return iParts [k ] < jParts [k ]
499+ }
491500 }
501+
502+ // If all compared parts are equal, the shorter name (parent) comes first
503+ if len (iParts ) != len (jParts ) {
504+ return len (iParts ) < len (jParts )
505+ }
506+
507+ // Finally, compare PassRatio if everything else is equal
492508 return results [i ].PassRatio < results [j ].PassRatio
493509 })
494510}
0 commit comments