@@ -40,6 +40,7 @@ use joinery::JoinableIterator;
4040use miette:: { miette, Diagnostic , IntoDiagnostic , NamedSource , Report , SourceSpan , WrapErr } ;
4141use path_dsl:: path;
4242use rayon:: prelude:: { IntoParallelIterator , ParallelIterator } ;
43+ use shared:: Browser ;
4344use wax:: Glob ;
4445use whippit:: {
4546 metadata:: SectionHeader ,
@@ -49,8 +50,10 @@ use whippit::{
4950#[ derive( Debug , Parser ) ]
5051#[ command( about, version) ]
5152struct Cli {
52- #[ clap( long) ]
53- gecko_checkout : Option < PathBuf > ,
53+ #[ clap( long, alias = "gecko-checkout" ) ]
54+ checkout : Option < PathBuf > ,
55+ #[ clap( value_enum, long, default_value_t = Default :: default ( ) ) ]
56+ browser : Browser ,
5457 #[ clap( subcommand) ]
5558 subcommand : Subcommand ,
5659}
@@ -129,14 +132,12 @@ fn main() -> ExitCode {
129132
130133fn run ( cli : Cli ) -> ExitCode {
131134 let Cli {
132- gecko_checkout,
135+ browser,
136+ checkout,
133137 subcommand,
134138 } = cli;
135139
136- let gecko_checkout = match gecko_checkout
137- . map ( Ok )
138- . unwrap_or_else ( search_for_moz_central_ckt)
139- {
140+ let checkout = match checkout. map ( Ok ) . unwrap_or_else ( search_for_moz_central_ckt) {
140141 Ok ( ckt_path) => ckt_path,
141142 Err ( AlreadyReportedToCommandline ) => return ExitCode :: FAILURE ,
142143 } ;
@@ -242,7 +243,7 @@ fn run(cli: Cli) -> ExitCode {
242243 log:: trace!( "working with the following WPT report files: {exec_report_paths:#?}" ) ;
243244 log:: info!( "working with {} WPT report files" , exec_report_paths. len( ) ) ;
244245
245- let meta_files_by_path = match read_and_parse_all_metadata ( & gecko_checkout )
246+ let meta_files_by_path = match read_and_parse_all_metadata ( browser , & checkout )
246247 . collect :: < Result < IndexMap < _ , _ > , _ > > ( )
247248 {
248249 Ok ( paths) => paths,
@@ -274,7 +275,7 @@ fn run(cli: Cli) -> ExitCode {
274275 for ( path, file) in meta_files_by_path {
275276 let File { properties, tests } = file;
276277
277- let file_rel_path = path. strip_prefix ( & gecko_checkout ) . unwrap ( ) ;
278+ let file_rel_path = path. strip_prefix ( & checkout ) . unwrap ( ) ;
278279
279280 file_props_by_file. insert (
280281 Utf8PathBuf :: from ( file_rel_path. to_str ( ) . unwrap ( ) ) ,
@@ -287,7 +288,7 @@ fn run(cli: Cli) -> ExitCode {
287288 subtests,
288289 } = test;
289290
290- let test_path = TestPath :: from_fx_metadata_test ( file_rel_path, & name) . unwrap ( ) ;
291+ let test_path = TestPath :: from_metadata_test ( file_rel_path, & name) . unwrap ( ) ;
291292
292293 let freak_out_do_nothing = |what : & dyn Display | {
293294 log:: error!( "hoo boy, not sure what to do yet: {what}" )
@@ -400,7 +401,7 @@ fn run(cli: Cli) -> ExitCode {
400401 for entry in entries {
401402 let TestExecutionEntry { test_name, result } = entry;
402403
403- let test_path = TestPath :: from_execution_report ( & test_name) . unwrap ( ) ;
404+ let test_path = TestPath :: from_execution_report ( & test_name, browser ) . unwrap ( ) ;
404405 let TestEntry {
405406 entry : test_entry,
406407 subtests : subtest_entries,
@@ -645,8 +646,8 @@ fn run(cli: Cli) -> ExitCode {
645646 let mut files = BTreeMap :: < PathBuf , File > :: new ( ) ;
646647 for ( test_path, ( properties, subtests) ) in recombined_tests_iter {
647648 let name = test_path. test_name ( ) . to_string ( ) ;
648- let rel_path = Utf8PathBuf :: from ( test_path. rel_metadata_path_fx ( ) . to_string ( ) ) ;
649- let path = gecko_checkout . join ( & rel_path) ;
649+ let rel_path = Utf8PathBuf :: from ( test_path. rel_metadata_path ( ) . to_string ( ) ) ;
650+ let path = checkout . join ( & rel_path) ;
650651 let file = files. entry ( path) . or_insert_with ( || File {
651652 properties : file_props_by_file
652653 . get ( & rel_path)
@@ -714,7 +715,7 @@ fn run(cli: Cli) -> ExitCode {
714715 }
715716 Subcommand :: Fixup => {
716717 log:: info!( "fixing up metadata in-place…" ) ;
717- let err_found = read_and_parse_all_metadata ( & gecko_checkout )
718+ let err_found = read_and_parse_all_metadata ( browser , & checkout )
718719 . map ( |res| {
719720 res. and_then ( |( path, mut file) | {
720721 for test in file. tests . values_mut ( ) {
@@ -752,7 +753,7 @@ fn run(cli: Cli) -> ExitCode {
752753 inner : Test ,
753754 }
754755 let mut err_found = false ;
755- let tests_by_name = read_and_parse_all_metadata ( & gecko_checkout )
756+ let tests_by_name = read_and_parse_all_metadata ( browser , & checkout )
756757 . map_ok (
757758 |(
758759 path,
@@ -762,11 +763,11 @@ fn run(cli: Cli) -> ExitCode {
762763 } ,
763764 ) | {
764765 tests. into_iter ( ) . map ( {
765- let gecko_checkout = & gecko_checkout ;
766+ let checkout = & checkout ;
766767 move |( name, inner) | {
767768 let SectionHeader ( name) = & name;
768- let test_path = TestPath :: from_fx_metadata_test (
769- path. strip_prefix ( gecko_checkout ) . unwrap ( ) ,
769+ let test_path = TestPath :: from_metadata_test (
770+ path. strip_prefix ( checkout ) . unwrap ( ) ,
770771 name,
771772 )
772773 . unwrap ( ) ;
@@ -1314,13 +1315,17 @@ fn run(cli: Cli) -> ExitCode {
13141315}
13151316
13161317fn read_and_parse_all_metadata (
1317- gecko_checkout : & Path ,
1318+ browser : Browser ,
1319+ checkout : & Path ,
13181320) -> impl Iterator < Item = Result < ( Arc < PathBuf > , metadata:: File ) , AlreadyReportedToCommandline > > {
1319- let webgpu_cts_meta_parent_dir =
1320- path ! ( gecko_checkout | "testing" | "web-platform" | "mozilla" | "meta" | "webgpu" ) ;
1321+ let webgpu_cts_meta_parent_dir = match browser {
1322+ Browser :: Firefox => {
1323+ path ! ( & checkout | "testing" | "web-platform" | "mozilla" | "meta" | "webgpu" )
1324+ }
1325+ Browser :: Servo => path ! ( & checkout | "tests" | "wpt" | "webgpu" | "meta" | "webgpu" ) ,
1326+ } ;
13211327
1322- let raw_metadata_files =
1323- read_gecko_files_at ( gecko_checkout, & webgpu_cts_meta_parent_dir, "**/*.ini" ) ;
1328+ let raw_metadata_files = read_files_at ( checkout, & webgpu_cts_meta_parent_dir, "**/*.ini" ) ;
13241329
13251330 let mut started_parsing = false ;
13261331 raw_metadata_files. filter_map ( move |res| {
@@ -1381,20 +1386,20 @@ fn render_metadata_parse_errors<'a>(
13811386}
13821387
13831388/// Returns a "naturally" sorted list of files found by searching for `glob_pattern` in `base`.
1384- /// `gecko_checkout ` is stripped as a prefix from the absolute paths recorded into `log` entries
1389+ /// `checkout ` is stripped as a prefix from the absolute paths recorded into `log` entries
13851390/// emitted by this function.
13861391///
13871392/// # Returns
13881393///
1389- /// An iterator over [`Result`]s containing either a Gecko file's path and contents as a UTF-8
1394+ /// An iterator over [`Result`]s containing either a checkout file's path and contents as a UTF-8
13901395/// string, or the sentinel of an error encountered for the same file that is already reported to
13911396/// the command line.
13921397///
13931398/// # Panics
13941399///
1395- /// This function will panick if `gecko_checkout ` cannot be stripped as a prefix of `base`.
1396- fn read_gecko_files_at (
1397- gecko_checkout : & Path ,
1400+ /// This function will panick if `checkout ` cannot be stripped as a prefix of `base`.
1401+ fn read_files_at (
1402+ checkout : & Path ,
13981403 base : & Path ,
13991404 glob_pattern : & str ,
14001405) -> impl Iterator < Item = Result < ( PathBuf , String ) , AlreadyReportedToCommandline > > {
@@ -1408,7 +1413,7 @@ fn read_gecko_files_at(
14081413 Err ( e) => {
14091414 let path_disp = e
14101415 . path ( )
1411- . map ( |p| format ! ( " in {}" , p. strip_prefix( gecko_checkout ) . unwrap( ) . display( ) ) ) ;
1416+ . map ( |p| format ! ( " in {}" , p. strip_prefix( checkout ) . unwrap( ) . display( ) ) ) ;
14121417 let path_disp: & dyn Display = match path_disp. as_ref ( ) {
14131418 Some ( disp) => disp,
14141419 None => & "" ,
@@ -1430,7 +1435,7 @@ fn read_gecko_files_at(
14301435 "working with these files: {:#?}" ,
14311436 paths
14321437 . iter( )
1433- . map( |f| f. strip_prefix( gecko_checkout ) . unwrap( ) )
1438+ . map( |f| f. strip_prefix( checkout ) . unwrap( ) )
14341439 . collect:: <std:: collections:: BTreeSet <_>>( )
14351440 ) ;
14361441
0 commit comments