@@ -35,6 +35,7 @@ use joinery::JoinableIterator;
3535use miette:: { miette, Diagnostic , IntoDiagnostic , NamedSource , Report , SourceSpan , WrapErr } ;
3636use path_dsl:: path;
3737use rayon:: prelude:: { IntoParallelIterator , ParallelIterator } ;
38+ use shared:: Browser ;
3839use strum:: IntoEnumIterator ;
3940use wax:: Glob ;
4041use whippit:: {
@@ -45,8 +46,10 @@ use whippit::{
4546#[ derive( Debug , Parser ) ]
4647#[ command( about, version) ]
4748struct Cli {
48- #[ clap( long) ]
49- gecko_checkout : Option < PathBuf > ,
49+ #[ clap( long, alias = "gecko-checkout" ) ]
50+ checkout : Option < PathBuf > ,
51+ #[ clap( value_enum, long, default_value_t = Default :: default ( ) ) ]
52+ browser : Browser ,
5053 #[ clap( subcommand) ]
5154 subcommand : Subcommand ,
5255}
@@ -123,35 +126,36 @@ fn main() -> ExitCode {
123126
124127fn run ( cli : Cli ) -> ExitCode {
125128 let Cli {
126- gecko_checkout,
129+ browser,
130+ checkout,
127131 subcommand,
128132 } = cli;
129133
130- let gecko_checkout = match gecko_checkout
131- . map ( Ok )
132- . unwrap_or_else ( search_for_moz_central_ckt)
133- {
134+ let checkout = match checkout. map ( Ok ) . unwrap_or_else ( search_for_moz_central_ckt) {
134135 Ok ( ckt_path) => ckt_path,
135136 Err ( AlreadyReportedToCommandline ) => return ExitCode :: FAILURE ,
136137 } ;
137138
138139 let read_metadata = || -> Result < _ , AlreadyReportedToCommandline > {
139- let webgpu_cts_meta_parent_dir =
140- { path ! ( & gecko_checkout | "testing" | "web-platform" | "mozilla" | "meta" | "webgpu" ) } ;
140+ let webgpu_cts_meta_parent_dir = match browser {
141+ Browser :: Firefox => {
142+ path ! ( & checkout | "testing" | "web-platform" | "mozilla" | "meta" | "webgpu" )
143+ }
144+ Browser :: Servo => path ! ( & checkout | "tests" | "wpt" | "webgpu" | "meta" | "webgpu" ) ,
145+ } ;
141146
142147 let mut found_err = false ;
143- let collected =
144- read_gecko_files_at ( & gecko_checkout, & webgpu_cts_meta_parent_dir, "**/*.ini" ) ?
145- . filter_map ( |res| match res {
146- Ok ( ( p, _contents) ) if p. ends_with ( "__dir__.ini" ) => None ,
147- Ok ( ok) => Some ( ok) ,
148- Err ( AlreadyReportedToCommandline ) => {
149- found_err = true ;
150- None
151- }
152- } )
153- . map ( |( p, fc) | ( Arc :: new ( p) , Arc :: new ( fc) ) )
154- . collect :: < IndexMap < _ , _ > > ( ) ;
148+ let collected = read_files_at ( & checkout, & webgpu_cts_meta_parent_dir, "**/*.ini" ) ?
149+ . filter_map ( |res| match res {
150+ Ok ( ( p, _contents) ) if p. ends_with ( "__dir__.ini" ) => None ,
151+ Ok ( ok) => Some ( ok) ,
152+ Err ( AlreadyReportedToCommandline ) => {
153+ found_err = true ;
154+ None
155+ }
156+ } )
157+ . map ( |( p, fc) | ( Arc :: new ( p) , Arc :: new ( fc) ) )
158+ . collect :: < IndexMap < _ , _ > > ( ) ;
155159 if found_err {
156160 Err ( AlreadyReportedToCommandline )
157161 } else {
@@ -337,7 +341,7 @@ fn run(cli: Cli) -> ExitCode {
337341 for ( path, file) in meta_files_by_path {
338342 let File { properties, tests } = file;
339343
340- let file_rel_path = path. strip_prefix ( & gecko_checkout ) . unwrap ( ) ;
344+ let file_rel_path = path. strip_prefix ( & checkout ) . unwrap ( ) ;
341345
342346 file_props_by_file. insert (
343347 Utf8PathBuf :: from ( file_rel_path. to_str ( ) . unwrap ( ) ) ,
@@ -350,7 +354,7 @@ fn run(cli: Cli) -> ExitCode {
350354 subtests,
351355 } = test;
352356
353- let test_path = TestPath :: from_fx_metadata_test ( file_rel_path, & name) . unwrap ( ) ;
357+ let test_path = TestPath :: from_metadata_test ( file_rel_path, & name) . unwrap ( ) ;
354358
355359 let freak_out_do_nothing = |what : & dyn Display | {
356360 log:: error!( "hoo boy, not sure what to do yet: {what}" )
@@ -461,7 +465,7 @@ fn run(cli: Cli) -> ExitCode {
461465 for entry in entries {
462466 let TestExecutionEntry { test_name, result } = entry;
463467
464- let test_path = TestPath :: from_execution_report ( & test_name) . unwrap ( ) ;
468+ let test_path = TestPath :: from_execution_report ( & test_name, browser ) . unwrap ( ) ;
465469 let TestEntry {
466470 entry : test_entry,
467471 subtests : subtest_entries,
@@ -707,8 +711,8 @@ fn run(cli: Cli) -> ExitCode {
707711 let mut files = BTreeMap :: < PathBuf , File > :: new ( ) ;
708712 for ( test_path, ( properties, subtests) ) in recombined_tests_iter {
709713 let name = test_path. test_name ( ) . to_string ( ) ;
710- let rel_path = Utf8PathBuf :: from ( test_path. rel_metadata_path_fx ( ) . to_string ( ) ) ;
711- let path = gecko_checkout . join ( & rel_path) ;
714+ let rel_path = Utf8PathBuf :: from ( test_path. rel_metadata_path ( ) . to_string ( ) ) ;
715+ let path = checkout . join ( & rel_path) ;
712716 let file = files. entry ( path) . or_insert_with ( || File {
713717 properties : file_props_by_file
714718 . get ( & rel_path)
@@ -829,11 +833,11 @@ fn run(cli: Cli) -> ExitCode {
829833 properties : _,
830834 tests,
831835 } ) => Some ( tests. into_iter ( ) . map ( {
832- let gecko_checkout = & gecko_checkout ;
836+ let checkout = & checkout ;
833837 move |( name, inner) | {
834838 let SectionHeader ( name) = & name;
835- let test_path = TestPath :: from_fx_metadata_test (
836- path. strip_prefix ( gecko_checkout ) . unwrap ( ) ,
839+ let test_path = TestPath :: from_metadata_test (
840+ path. strip_prefix ( checkout ) . unwrap ( ) ,
837841 name,
838842 )
839843 . unwrap ( ) ;
@@ -1459,20 +1463,20 @@ fn run(cli: Cli) -> ExitCode {
14591463}
14601464
14611465/// Returns a "naturally" sorted list of files found by searching for `glob_pattern` in `base`.
1462- /// `gecko_checkout ` is stripped as a prefix from the absolute paths recorded into `log` entries
1466+ /// `checkout ` is stripped as a prefix from the absolute paths recorded into `log` entries
14631467/// emitted by this function.
14641468///
14651469/// # Returns
14661470///
1467- /// An iterator over [`Result`]s containing either a Gecko file's path and contents as a UTF-8
1471+ /// An iterator over [`Result`]s containing either a checkout file's path and contents as a UTF-8
14681472/// string, or the sentinel of an error encountered for the same file that is already reported to
14691473/// the command line.
14701474///
14711475/// # Panics
14721476///
1473- /// This function will panick if `gecko_checkout ` cannot be stripped as a prefix of `base`.
1474- fn read_gecko_files_at (
1475- gecko_checkout : & Path ,
1477+ /// This function will panick if `checkout ` cannot be stripped as a prefix of `base`.
1478+ fn read_files_at (
1479+ checkout : & Path ,
14761480 base : & Path ,
14771481 glob_pattern : & str ,
14781482) -> Result <
@@ -1489,7 +1493,7 @@ fn read_gecko_files_at(
14891493 Err ( e) => {
14901494 let path_disp = e
14911495 . path ( )
1492- . map ( |p| format ! ( " in {}" , p. strip_prefix( gecko_checkout ) . unwrap( ) . display( ) ) ) ;
1496+ . map ( |p| format ! ( " in {}" , p. strip_prefix( checkout ) . unwrap( ) . display( ) ) ) ;
14931497 let path_disp: & dyn Display = match path_disp. as_ref ( ) {
14941498 Some ( disp) => disp,
14951499 None => & "" ,
@@ -1511,7 +1515,7 @@ fn read_gecko_files_at(
15111515 "working with these files: {:#?}" ,
15121516 paths
15131517 . iter( )
1514- . map( |f| f. strip_prefix( gecko_checkout ) . unwrap( ) )
1518+ . map( |f| f. strip_prefix( checkout ) . unwrap( ) )
15151519 . collect:: <std:: collections:: BTreeSet <_>>( )
15161520 ) ;
15171521
0 commit comments