@@ -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,
@@ -680,8 +681,8 @@ fn run(cli: Cli) -> ExitCode {
680681 let mut files = BTreeMap :: < PathBuf , File > :: new ( ) ;
681682 for ( test_path, ( properties, subtests) ) in recombined_tests_iter {
682683 let name = test_path. test_name ( ) . to_string ( ) ;
683- let rel_path = Utf8PathBuf :: from ( test_path. rel_metadata_path_fx ( ) . to_string ( ) ) ;
684- let path = gecko_checkout . join ( & rel_path) ;
684+ let rel_path = Utf8PathBuf :: from ( test_path. rel_metadata_path ( ) . to_string ( ) ) ;
685+ let path = checkout . join ( & rel_path) ;
685686 let file = files. entry ( path) . or_insert_with ( || File {
686687 properties : file_props_by_file
687688 . get ( & rel_path)
@@ -749,7 +750,7 @@ fn run(cli: Cli) -> ExitCode {
749750 }
750751 Subcommand :: Fixup => {
751752 log:: info!( "fixing up metadata in-place…" ) ;
752- let err_found = read_and_parse_all_metadata ( & gecko_checkout )
753+ let err_found = read_and_parse_all_metadata ( browser , & checkout )
753754 . map ( |res| {
754755 res. and_then ( |( path, mut file) | {
755756 for test in file. tests . values_mut ( ) {
@@ -787,7 +788,7 @@ fn run(cli: Cli) -> ExitCode {
787788 inner : Test ,
788789 }
789790 let mut err_found = false ;
790- let tests_by_name = read_and_parse_all_metadata ( & gecko_checkout )
791+ let tests_by_name = read_and_parse_all_metadata ( browser , & checkout )
791792 . map_ok (
792793 |(
793794 path,
@@ -797,11 +798,11 @@ fn run(cli: Cli) -> ExitCode {
797798 } ,
798799 ) | {
799800 tests. into_iter ( ) . map ( {
800- let gecko_checkout = & gecko_checkout ;
801+ let checkout = & checkout ;
801802 move |( name, inner) | {
802803 let SectionHeader ( name) = & name;
803- let test_path = TestPath :: from_fx_metadata_test (
804- path. strip_prefix ( gecko_checkout ) . unwrap ( ) ,
804+ let test_path = TestPath :: from_metadata_test (
805+ path. strip_prefix ( checkout ) . unwrap ( ) ,
805806 name,
806807 )
807808 . unwrap ( ) ;
@@ -1351,13 +1352,17 @@ fn run(cli: Cli) -> ExitCode {
13511352}
13521353
13531354fn read_and_parse_all_metadata (
1354- gecko_checkout : & Path ,
1355+ browser : Browser ,
1356+ checkout : & Path ,
13551357) -> impl Iterator < Item = Result < ( Arc < PathBuf > , metadata:: File ) , AlreadyReportedToCommandline > > {
1356- let webgpu_cts_meta_parent_dir =
1357- path ! ( gecko_checkout | "testing" | "web-platform" | "mozilla" | "meta" | "webgpu" ) ;
1358+ let webgpu_cts_meta_parent_dir = match browser {
1359+ Browser :: Firefox => {
1360+ path ! ( & checkout | "testing" | "web-platform" | "mozilla" | "meta" | "webgpu" )
1361+ }
1362+ Browser :: Servo => path ! ( & checkout | "tests" | "wpt" | "webgpu" | "meta" | "webgpu" ) ,
1363+ } ;
13581364
1359- let raw_metadata_files =
1360- read_gecko_files_at ( gecko_checkout, & webgpu_cts_meta_parent_dir, "**/*.ini" ) ;
1365+ let raw_metadata_files = read_files_at ( checkout, & webgpu_cts_meta_parent_dir, "**/*.ini" ) ;
13611366
13621367 let mut started_parsing = false ;
13631368 raw_metadata_files. filter_map ( move |res| {
@@ -1418,20 +1423,20 @@ fn render_metadata_parse_errors<'a>(
14181423}
14191424
14201425/// Returns a "naturally" sorted list of files found by searching for `glob_pattern` in `base`.
1421- /// `gecko_checkout ` is stripped as a prefix from the absolute paths recorded into `log` entries
1426+ /// `checkout ` is stripped as a prefix from the absolute paths recorded into `log` entries
14221427/// emitted by this function.
14231428///
14241429/// # Returns
14251430///
1426- /// An iterator over [`Result`]s containing either a Gecko file's path and contents as a UTF-8
1431+ /// An iterator over [`Result`]s containing either a checkout file's path and contents as a UTF-8
14271432/// string, or the sentinel of an error encountered for the same file that is already reported to
14281433/// the command line.
14291434///
14301435/// # Panics
14311436///
1432- /// This function will panick if `gecko_checkout ` cannot be stripped as a prefix of `base`.
1433- fn read_gecko_files_at (
1434- gecko_checkout : & Path ,
1437+ /// This function will panick if `checkout ` cannot be stripped as a prefix of `base`.
1438+ fn read_files_at (
1439+ checkout : & Path ,
14351440 base : & Path ,
14361441 glob_pattern : & str ,
14371442) -> impl Iterator < Item = Result < ( PathBuf , String ) , AlreadyReportedToCommandline > > {
@@ -1445,7 +1450,7 @@ fn read_gecko_files_at(
14451450 Err ( e) => {
14461451 let path_disp = e
14471452 . path ( )
1448- . map ( |p| format ! ( " in {}" , p. strip_prefix( gecko_checkout ) . unwrap( ) . display( ) ) ) ;
1453+ . map ( |p| format ! ( " in {}" , p. strip_prefix( checkout ) . unwrap( ) . display( ) ) ) ;
14491454 let path_disp: & dyn Display = match path_disp. as_ref ( ) {
14501455 Some ( disp) => disp,
14511456 None => & "" ,
@@ -1467,7 +1472,7 @@ fn read_gecko_files_at(
14671472 "working with these files: {:#?}" ,
14681473 paths
14691474 . iter( )
1470- . map( |f| f. strip_prefix( gecko_checkout ) . unwrap( ) )
1475+ . map( |f| f. strip_prefix( checkout ) . unwrap( ) )
14711476 . collect:: <std:: collections:: BTreeSet <_>>( )
14721477 ) ;
14731478
0 commit comments