@@ -2,9 +2,10 @@ use crate::assets;
2
2
use crate :: experiments:: Experiment ;
3
3
use crate :: prelude:: * ;
4
4
use crate :: report:: {
5
- archives:: Archive , Color , Comparison , ReportWriter , ResultColor , ResultName , TestResults ,
5
+ analyzer:: ReportCrates , archives:: Archive , Color , Comparison , CrateResult , ReportWriter ,
6
+ ResultColor , ResultName , TestResults ,
6
7
} ;
7
- use crate :: results:: EncodingType ;
8
+ use crate :: results:: { EncodingType , FailureReason , TestResult } ;
8
9
use std:: collections:: HashMap ;
9
10
10
11
#[ derive( Serialize ) ]
@@ -21,6 +22,19 @@ enum CurrentPage {
21
22
Downloads ,
22
23
}
23
24
25
+ #[ derive( Serialize ) ]
26
+ enum ReportCratesHTML {
27
+ Plain ( Vec < CrateResultHTML > ) ,
28
+ Tree {
29
+ count : u32 ,
30
+ tree : HashMap < String , Vec < CrateResultHTML > > ,
31
+ } ,
32
+ RootResults {
33
+ count : u32 ,
34
+ results : HashMap < String , Vec < CrateResultHTML > > ,
35
+ } ,
36
+ }
37
+
24
38
impl CurrentPage {
25
39
fn navbar ( & self ) -> Vec < NavbarItem > {
26
40
vec ! [
@@ -47,7 +61,8 @@ impl CurrentPage {
47
61
struct ResultsContext < ' a > {
48
62
ex : & ' a Experiment ,
49
63
nav : Vec < NavbarItem > ,
50
- categories : HashMap < Comparison , Vec < CrateResultHTML > > ,
64
+ categories : Vec < ( Comparison , ReportCratesHTML ) > ,
65
+ info : HashMap < Comparison , u32 > ,
51
66
full : bool ,
52
67
crates_count : usize ,
53
68
@@ -93,43 +108,103 @@ fn write_report<W: ReportWriter>(
93
108
let mut result_colors = Vec :: new ( ) ;
94
109
let mut result_names = Vec :: new ( ) ;
95
110
96
- let mut categories = HashMap :: new ( ) ;
97
- for result in & res. crates {
98
- // Skip some categories if this is not the full report
99
- if !full && !result. res . show_in_summary ( ) {
100
- continue ;
101
- }
102
-
103
- // Add the colors and names used in this run
104
- comparison_colors
105
- . entry ( result. res )
106
- . or_insert_with ( || result. res . color ( ) ) ;
107
-
111
+ let mut to_html_crate_result = |result : CrateResult | {
108
112
let mut runs = [ None , None ] ;
109
113
110
114
for ( pos, run) in result. runs . iter ( ) . enumerate ( ) {
111
115
if let Some ( ref run) = run {
112
- let idx = test_results_to_int. entry ( & run. res ) . or_insert_with ( || {
113
- result_colors. push ( run. res . color ( ) ) ;
114
- result_names. push ( run. res . name ( ) ) ;
115
- result_names. len ( ) - 1
116
- } ) ;
116
+ let idx = test_results_to_int
117
+ . entry ( run. res . clone ( ) )
118
+ . or_insert_with ( || {
119
+ result_colors. push ( run. res . color ( ) ) ;
120
+ result_names. push ( run. res . name ( ) ) ;
121
+ result_names. len ( ) - 1
122
+ } ) ;
117
123
runs[ pos] = Some ( BuildTestResultHTML {
118
124
res : * idx as usize ,
119
125
log : run. log . clone ( ) ,
120
126
} ) ;
121
127
}
122
128
}
123
129
124
- let category = categories. entry ( result. res ) . or_insert_with ( Vec :: new) ;
125
- let result = CrateResultHTML {
130
+ CrateResultHTML {
126
131
name : result. name . clone ( ) ,
127
132
url : result. url . clone ( ) ,
128
133
res : result. res ,
129
134
runs,
130
- } ;
131
- category. push ( result) ;
132
- }
135
+ }
136
+ } ;
137
+
138
+ let categories = res
139
+ . categories
140
+ . iter ( )
141
+ . filter ( |( category, _) | full || category. show_in_summary ( ) )
142
+ . map ( |( & category, crates) | ( category, crates. to_owned ( ) ) )
143
+ . flat_map ( |( category, crates) | {
144
+ comparison_colors. insert ( category, category. color ( ) ) ;
145
+
146
+ match crates {
147
+ ReportCrates :: Plain ( crates) => vec ! [ (
148
+ category,
149
+ ReportCratesHTML :: Plain (
150
+ crates
151
+ . into_iter( )
152
+ . map( |result| to_html_crate_result( result) )
153
+ . collect:: <Vec <_>>( ) ,
154
+ ) ,
155
+ ) ]
156
+ . into_iter ( ) ,
157
+ ReportCrates :: Complete { tree, results } => {
158
+ let tree = tree
159
+ . into_iter ( )
160
+ . map ( |( root, deps) | {
161
+ (
162
+ root. to_string ( ) ,
163
+ deps. into_iter ( )
164
+ . map ( |result| to_html_crate_result ( result) )
165
+ . collect :: < Vec < _ > > ( ) ,
166
+ )
167
+ } )
168
+ . collect :: < HashMap < _ , _ > > ( ) ;
169
+ let results = results
170
+ . into_iter ( )
171
+ . map ( |( res, krates) | {
172
+ (
173
+ if let TestResult :: BuildFail ( FailureReason :: CompilerError ( _) ) = res
174
+ {
175
+ res. to_string ( )
176
+ } else {
177
+ res. name ( )
178
+ } ,
179
+ krates
180
+ . into_iter ( )
181
+ . map ( |result| to_html_crate_result ( result) )
182
+ . collect :: < Vec < _ > > ( ) ,
183
+ )
184
+ } )
185
+ . collect :: < HashMap < _ , _ > > ( ) ;
186
+
187
+ vec ! [
188
+ (
189
+ category,
190
+ ReportCratesHTML :: Tree {
191
+ count: tree. keys( ) . len( ) as u32 ,
192
+ tree,
193
+ } ,
194
+ ) ,
195
+ (
196
+ category,
197
+ ReportCratesHTML :: RootResults {
198
+ count: results. keys( ) . len( ) as u32 ,
199
+ results,
200
+ } ,
201
+ ) ,
202
+ ]
203
+ . into_iter ( )
204
+ }
205
+ }
206
+ } )
207
+ . collect ( ) ;
133
208
134
209
let context = ResultsContext {
135
210
ex,
@@ -140,6 +215,7 @@ fn write_report<W: ReportWriter>(
140
215
}
141
216
. navbar ( ) ,
142
217
categories,
218
+ info : res. info . clone ( ) ,
143
219
full,
144
220
crates_count,
145
221
comparison_colors,
0 commit comments