11use crate :: prelude:: * ;
22use crate :: report:: Comparison ;
3- use crate :: results:: { BrokenReason , FailureReason , TestResult } ;
3+ use crate :: results:: { BrokenReason , FailureReason , StatFailureReasons , TestResult } ;
4+ use std:: collections:: HashMap ;
45
56pub trait ResultName {
67 fn short_name ( & self ) -> String ;
@@ -38,6 +39,41 @@ impl ResultName for FailureReason {
3839 }
3940}
4041
42+ impl ResultName for StatFailureReasons {
43+ fn short_name ( & self ) -> String {
44+ let StatFailureReasons :: Reasons ( vec) = self else {
45+ return String :: new ( ) ;
46+ } ;
47+ // ex: "failed (unknown) x2 | OOM x4 | ICE x1"
48+ let unique_counts: HashMap < String , usize > =
49+ vec. iter ( ) . fold ( HashMap :: new ( ) , |mut map, val| {
50+ * map. entry ( val. short_name ( ) ) . or_insert ( 0 ) += 1 ;
51+ map
52+ } ) ;
53+ unique_counts
54+ . iter ( )
55+ . map ( |v| format ! ( "{} x{}" , v. 0 , v. 1 ) )
56+ . collect :: < Vec < _ > > ( )
57+ . join ( " | " )
58+ }
59+
60+ fn long_name ( & self ) -> String {
61+ let StatFailureReasons :: Reasons ( vec) = self else {
62+ return String :: new ( ) ;
63+ } ;
64+ let unique_counts: HashMap < String , usize > =
65+ vec. iter ( ) . fold ( HashMap :: new ( ) , |mut map, val| {
66+ * map. entry ( val. long_name ( ) ) . or_insert ( 0 ) += 1 ;
67+ map
68+ } ) ;
69+ unique_counts
70+ . iter ( )
71+ . map ( |v| format ! ( "{} x{}" , v. 0 , v. 1 ) )
72+ . collect :: < Vec < _ > > ( )
73+ . join ( " | " )
74+ }
75+ }
76+
4177impl ResultName for BrokenReason {
4278 fn short_name ( & self ) -> String {
4379 match self {
@@ -61,6 +97,7 @@ impl ResultName for TestResult {
6197 TestResult :: PrepareFail ( reason) => format ! ( "prepare {}" , reason. short_name( ) ) ,
6298 TestResult :: BuildFail ( reason) => format ! ( "build {}" , reason. short_name( ) ) ,
6399 TestResult :: TestFail ( reason) => format ! ( "test {}" , reason. short_name( ) ) ,
100+ TestResult :: TestsFail ( reason) => format ! ( "tests: {}" , reason. short_name( ) ) ,
64101 TestResult :: TestSkipped => "test skipped" . into ( ) ,
65102 TestResult :: TestPass => "test passed" . into ( ) ,
66103 TestResult :: Error => "error" . into ( ) ,
@@ -73,6 +110,7 @@ impl ResultName for TestResult {
73110 TestResult :: PrepareFail ( reason) => format ! ( "prepare {}" , reason. long_name( ) ) ,
74111 TestResult :: BuildFail ( reason) => format ! ( "build {}" , reason. long_name( ) ) ,
75112 TestResult :: TestFail ( reason) => format ! ( "test {}" , reason. long_name( ) ) ,
113+ TestResult :: TestsFail ( reason) => format ! ( "tests: {}" , reason. long_name( ) ) ,
76114 TestResult :: BrokenCrate ( reason) => reason. long_name ( ) ,
77115 TestResult :: TestSkipped
78116 | TestResult :: TestPass
@@ -118,6 +156,7 @@ impl ResultColor for TestResult {
118156 TestResult :: BrokenCrate ( _) => Color :: Single ( "#44176e" ) ,
119157 TestResult :: BuildFail ( _) => Color :: Single ( "#db3026" ) ,
120158 TestResult :: TestFail ( _) => Color :: Single ( "#65461e" ) ,
159+ TestResult :: TestsFail ( _) => Color :: Single ( "#65461e" ) ,
121160 TestResult :: TestSkipped | TestResult :: TestPass => Color :: Single ( "#62a156" ) ,
122161 TestResult :: Error => Color :: Single ( "#d77026" ) ,
123162 TestResult :: PrepareFail ( _) => Color :: Striped ( "#44176e" , "#d77026" ) ,
0 commit comments