|
4 | 4 | mod args;
|
5 | 5 | mod reporters;
|
6 | 6 |
|
7 |
| -use crate::reporters::terminal::TerminalReporter; |
8 |
| -pub use args::Args; |
| 7 | +use args::Args; |
9 | 8 | use clap::Parser;
|
10 |
| -use fontspector_checkapi::{Check, CheckResult, Context, Plugin, Registry, StatusCode, Testable}; |
| 9 | +use fontspector_checkapi::{Check, Context, Plugin, Registry, Testable}; |
11 | 10 | use indicatif::ParallelProgressIterator;
|
12 | 11 | use profile_googlefonts::GoogleFonts;
|
13 | 12 | use profile_universal::Universal;
|
14 | 13 | use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
15 |
| -use reporters::Reporter; |
| 14 | +use reporters::{ |
| 15 | + organize, summary_results, terminal::TerminalReporter, worst_status, Reporter, RunResults, |
| 16 | +}; |
16 | 17 | use serde_json::Map;
|
17 |
| -use std::collections::HashMap; |
18 | 18 |
|
19 | 19 | /// Filter out checks that don't apply
|
20 | 20 | fn included_excluded(checkname: &str, args: &Args) -> bool {
|
@@ -124,39 +124,38 @@ fn main() {
|
124 | 124 | })
|
125 | 125 | .collect();
|
126 | 126 |
|
127 |
| - println!("Testing..."); |
128 |
| - let results: Vec<_> = checkorder |
| 127 | + if !args.quiet { |
| 128 | + println!( |
| 129 | + "Running {:} check{} on {:} file{}", |
| 130 | + checkorder.len(), |
| 131 | + if checkorder.len() == 1 { "" } else { "s" }, |
| 132 | + testables.len(), |
| 133 | + if testables.len() == 1 { "" } else { "s" } |
| 134 | + ); |
| 135 | + } |
| 136 | + |
| 137 | + let results: RunResults = checkorder |
129 | 138 | .par_iter()
|
130 | 139 | .progress()
|
131 | 140 | .map(|(sectionname, testable, check, context)| {
|
132 | 141 | (sectionname, testable, check.run_one(testable, context))
|
133 | 142 | })
|
134 | 143 | .collect();
|
135 | 144 |
|
136 |
| - let worst_status = results |
137 |
| - .iter() |
138 |
| - .map(|(_sectionname, _testable, checkresults)| { |
139 |
| - checkresults |
140 |
| - .iter() |
141 |
| - .map(|r| r.status.code) |
142 |
| - .max() |
143 |
| - .unwrap_or(StatusCode::Pass) |
144 |
| - }) |
145 |
| - .max() |
146 |
| - .unwrap_or(StatusCode::Pass); |
| 145 | + let worst_status = worst_status(&results); |
147 | 146 |
|
148 | 147 | // Organise results by testable and sectionname
|
149 |
| - let mut organised_results: HashMap<&Testable, HashMap<String, Vec<CheckResult>>> = |
150 |
| - HashMap::new(); |
151 |
| - for (sectionname, testable, checkresults) in results { |
152 |
| - // let filename = testable.filename.clone(); |
153 |
| - let section = organised_results.entry(testable).or_default(); |
154 |
| - let results = section.entry(sectionname.clone()).or_default(); |
155 |
| - results.extend(checkresults); |
156 |
| - } |
| 148 | + let organised_results = organize(results); |
157 | 149 |
|
158 | 150 | if !args.quiet {
|
159 | 151 | TerminalReporter {}.report(&organised_results, &args, ®istry);
|
| 152 | + // Summary report |
| 153 | + let summary = summary_results(organised_results); |
| 154 | + print!("\nSummary:\n "); |
| 155 | + for (status, count) in summary.iter() { |
| 156 | + print!("{:}: {:} ", status, count); |
| 157 | + } |
| 158 | + println!(); |
160 | 159 | }
|
161 | 160 | if worst_status >= args.error_code_on {
|
162 | 161 | std::process::exit(1);
|
|
0 commit comments