|
1 | 1 | use js_sys::{Reflect, Uint8Array};
|
2 | 2 | use wasm_bindgen::prelude::*;
|
3 | 3 | extern crate console_error_panic_hook;
|
4 |
| -use fontspector_checkapi::{Check, CheckResult, Context, Plugin, Registry, Testable}; |
| 4 | +use fontspector_checkapi::{ |
| 5 | + Check, CheckResult, Context, Plugin, Registry, Testable, TestableCollection, TestableType, |
| 6 | +}; |
5 | 7 | use profile_googlefonts::GoogleFonts;
|
6 | 8 | use profile_universal::Universal;
|
7 | 9 |
|
@@ -32,45 +34,29 @@ pub fn check_fonts(fonts: &JsValue) -> Result<String, JsValue> {
|
32 | 34 | }
|
33 | 35 | })
|
34 | 36 | .collect();
|
| 37 | + let collection = TestableCollection::from_testables(testables); |
| 38 | + |
35 | 39 | let profile = registry.get_profile("googlefonts").unwrap();
|
36 | 40 | let context = Context {
|
37 | 41 | skip_network: true,
|
38 | 42 | network_timeout: None,
|
39 | 43 | configuration: serde_json::Map::new(),
|
40 | 44 | };
|
| 45 | + let all_testables = collection.collection_and_files().collect(); |
41 | 46 |
|
42 |
| - let checkorder: Vec<(String, &Testable, &Check, Context)> = profile |
43 |
| - .sections |
44 |
| - .iter() |
45 |
| - .flat_map(|(sectionname, checknames)| { |
46 |
| - #[allow(clippy::unwrap_used)] // We previously ensured the check exists in the registry |
47 |
| - checknames |
48 |
| - .iter() |
49 |
| - // .filter(|checkname| included_excluded(checkname, &args)) |
50 |
| - .map(|checkname| { |
51 |
| - ( |
52 |
| - sectionname.clone(), |
53 |
| - registry.checks.get(checkname).unwrap(), |
54 |
| - context.clone(), |
55 |
| - ) |
56 |
| - }) |
57 |
| - }) |
58 |
| - .flat_map(|(sectionname, check, context): (String, &Check, Context)| { |
59 |
| - testables |
60 |
| - .iter() |
61 |
| - .filter(|testable| check.applies(testable, ®istry)) |
62 |
| - .map(move |testable| (sectionname.clone(), testable, check, context.clone())) |
63 |
| - }) |
64 |
| - .collect(); |
| 47 | + let checkorder: Vec<(String, &TestableType, &Check, Context)> = profile.check_order( |
| 48 | + &None, |
| 49 | + &None, |
| 50 | + ®istry, |
| 51 | + context, |
| 52 | + serde_json::Map::new(), |
| 53 | + &all_testables, |
| 54 | + ); |
65 | 55 |
|
66 | 56 | let results: Vec<CheckResult> = checkorder
|
67 | 57 | .iter()
|
68 | 58 | .map(|(sectionname, testable, check, context)| {
|
69 |
| - ( |
70 |
| - testable, |
71 |
| - check, |
72 |
| - check.run_one(testable, context, sectionname), |
73 |
| - ) |
| 59 | + (testable, check, check.run(testable, context, sectionname)) |
74 | 60 | })
|
75 | 61 | .flat_map(|(_, _, result)| result)
|
76 | 62 | .collect();
|
|
0 commit comments