|
| 1 | +mod file_spec; |
1 | 2 | mod process_reports; |
2 | 3 | mod report; |
3 | 4 | mod wpt; |
4 | 5 |
|
5 | | -use self::wpt::{ |
6 | | - metadata::{ |
7 | | - self, |
8 | | - properties::{ExpandedPropertyValue, Expected}, |
9 | | - File, ImplementationStatus, Platform, Subtest, SubtestOutcome, Test, TestOutcome, |
10 | | - TestProps, |
| 6 | +use self::{ |
| 7 | + file_spec::FileSpec, |
| 8 | + wpt::{ |
| 9 | + metadata::{ |
| 10 | + self, |
| 11 | + properties::{ExpandedPropertyValue, Expected}, |
| 12 | + File, ImplementationStatus, Platform, Subtest, SubtestOutcome, Test, TestOutcome, |
| 13 | + TestProps, |
| 14 | + }, |
| 15 | + path::TestEntryPath, |
11 | 16 | }, |
12 | | - path::TestEntryPath, |
13 | 17 | }; |
14 | 18 |
|
15 | 19 | use std::{ |
@@ -161,102 +165,11 @@ impl ExecReportSpec { |
161 | 165 | report_globs, |
162 | 166 | } = self; |
163 | 167 |
|
164 | | - let report_globs = { |
165 | | - let mut found_glob_parse_err = false; |
166 | | - let globs = report_globs |
167 | | - .into_iter() |
168 | | - .filter_map(|glob| match Glob::diagnosed(&glob) { |
169 | | - Ok((glob, _diagnostics)) => Some(glob.into_owned().partition()), |
170 | | - Err(diagnostics) => { |
171 | | - found_glob_parse_err = true; |
172 | | - let error_reports = diagnostics |
173 | | - .into_iter() |
174 | | - .filter(|diag| { |
175 | | - // N.B.: There should be at least one of these! |
176 | | - diag.severity() |
177 | | - .is_none_or(|sev| sev == miette::Severity::Error) |
178 | | - }) |
179 | | - .map(Report::new_boxed); |
180 | | - for report in error_reports { |
181 | | - eprintln!("{report:?}"); |
182 | | - } |
183 | | - None |
184 | | - } |
185 | | - }) |
186 | | - .collect::<Vec<_>>(); |
187 | | - |
188 | | - if found_glob_parse_err { |
189 | | - log::error!("failed to parse one or more WPT report globs; bailing"); |
190 | | - return Err(AlreadyReportedToCommandline); |
191 | | - } |
192 | | - |
193 | | - globs |
194 | | - }; |
195 | | - |
196 | | - let report_paths_from_glob = { |
197 | | - let mut found_glob_walk_err = false; |
198 | | - let files = report_globs |
199 | | - .iter() |
200 | | - .flat_map(|(base_path, glob)| { |
201 | | - glob.walk(base_path) |
202 | | - .filter_map(|entry| match entry { |
203 | | - Ok(entry) => Some(entry.into_path()), |
204 | | - Err(e) => { |
205 | | - found_glob_walk_err = true; |
206 | | - let ctx_msg = if let Some(path) = e.path() { |
207 | | - format!( |
208 | | - "failed to enumerate files for glob `{}` at path {}", |
209 | | - glob, |
210 | | - path.display() |
211 | | - ) |
212 | | - } else { |
213 | | - format!("failed to enumerate files for glob `{glob}`") |
214 | | - }; |
215 | | - let e = Report::msg(e).wrap_err(ctx_msg); |
216 | | - eprintln!("{e:?}"); |
217 | | - None |
218 | | - } |
219 | | - }) |
220 | | - .collect::<Vec<_>>() // OPT: Can we get rid of this somehow? |
221 | | - }) |
222 | | - .collect::<Vec<_>>(); |
223 | | - |
224 | | - if found_glob_walk_err { |
225 | | - log::error!(concat!( |
226 | | - "failed to enumerate files with WPT report globs, ", |
227 | | - "see above for more details" |
228 | | - )); |
229 | | - return Err(AlreadyReportedToCommandline); |
230 | | - } |
231 | | - |
232 | | - files |
233 | | - }; |
234 | | - |
235 | | - if report_paths_from_glob.is_empty() && !report_globs.is_empty() { |
236 | | - if report_paths.is_empty() { |
237 | | - log::error!(concat!( |
238 | | - "reports were specified exclusively via glob search, ", |
239 | | - "but none were found; bailing" |
240 | | - )); |
241 | | - return Err(AlreadyReportedToCommandline); |
242 | | - } else { |
243 | | - log::warn!(concat!( |
244 | | - "reports were specified via path and glob search, ", |
245 | | - "but none were found via glob; ", |
246 | | - "continuing with report paths" |
247 | | - )) |
248 | | - } |
| 168 | + FileSpec { |
| 169 | + paths: report_paths, |
| 170 | + globs: report_globs, |
249 | 171 | } |
250 | | - |
251 | | - let exec_report_paths = report_paths |
252 | | - .into_iter() |
253 | | - .chain(report_paths_from_glob) |
254 | | - .collect::<Vec<_>>(); |
255 | | - |
256 | | - log::trace!("working with the following WPT report files: {exec_report_paths:#?}"); |
257 | | - log::info!("working with {} WPT report files", exec_report_paths.len()); |
258 | | - |
259 | | - Ok(exec_report_paths) |
| 172 | + .into_paths("WPT report(s)") |
260 | 173 | } |
261 | 174 | } |
262 | 175 |
|
|
0 commit comments