@@ -39,6 +39,7 @@ use joinery::JoinableIterator;
3939use miette:: { miette, Diagnostic , IntoDiagnostic , NamedSource , Report , SourceSpan , WrapErr } ;
4040use path_dsl:: path;
4141use rayon:: prelude:: { IntoParallelIterator , ParallelIterator } ;
42+ use shared:: Browser ;
4243use wax:: Glob ;
4344use whippit:: {
4445 metadata:: SectionHeader ,
@@ -48,8 +49,10 @@ use whippit::{
4849#[ derive( Debug , Parser ) ]
4950#[ command( about, version) ]
5051struct Cli {
51- #[ clap( long) ]
52- gecko_checkout : Option < PathBuf > ,
52+ #[ clap( long, alias = "gecko-checkout" ) ]
53+ checkout : Option < PathBuf > ,
54+ #[ clap( value_enum, long, default_value_t = Default :: default ( ) ) ]
55+ browser : Browser ,
5356 #[ clap( subcommand) ]
5457 subcommand : Subcommand ,
5558}
@@ -126,35 +129,36 @@ fn main() -> ExitCode {
126129
127130fn run ( cli : Cli ) -> ExitCode {
128131 let Cli {
129- gecko_checkout,
132+ browser,
133+ checkout,
130134 subcommand,
131135 } = cli;
132136
133- let gecko_checkout = match gecko_checkout
134- . map ( Ok )
135- . unwrap_or_else ( search_for_moz_central_ckt)
136- {
137+ let checkout = match checkout. map ( Ok ) . unwrap_or_else ( search_for_moz_central_ckt) {
137138 Ok ( ckt_path) => ckt_path,
138139 Err ( AlreadyReportedToCommandline ) => return ExitCode :: FAILURE ,
139140 } ;
140141
141142 let read_metadata = || -> Result < _ , AlreadyReportedToCommandline > {
142- let webgpu_cts_meta_parent_dir =
143- { path ! ( & gecko_checkout | "testing" | "web-platform" | "mozilla" | "meta" | "webgpu" ) } ;
143+ let webgpu_cts_meta_parent_dir = match browser {
144+ Browser :: Firefox => {
145+ path ! ( & checkout | "testing" | "web-platform" | "mozilla" | "meta" | "webgpu" )
146+ }
147+ Browser :: Servo => path ! ( & checkout | "tests" | "wpt" | "webgpu" | "meta" | "webgpu" ) ,
148+ } ;
144149
145150 let mut found_err = false ;
146- let collected =
147- read_gecko_files_at ( & gecko_checkout, & webgpu_cts_meta_parent_dir, "**/*.ini" ) ?
148- . filter_map ( |res| match res {
149- Ok ( ( p, _contents) ) if p. ends_with ( "__dir__.ini" ) => None ,
150- Ok ( ok) => Some ( ok) ,
151- Err ( AlreadyReportedToCommandline ) => {
152- found_err = true ;
153- None
154- }
155- } )
156- . map ( |( p, fc) | ( Arc :: new ( p) , Arc :: new ( fc) ) )
157- . collect :: < IndexMap < _ , _ > > ( ) ;
151+ let collected = read_files_at ( & checkout, & webgpu_cts_meta_parent_dir, "**/*.ini" ) ?
152+ . filter_map ( |res| match res {
153+ Ok ( ( p, _contents) ) if p. ends_with ( "__dir__.ini" ) => None ,
154+ Ok ( ok) => Some ( ok) ,
155+ Err ( AlreadyReportedToCommandline ) => {
156+ found_err = true ;
157+ None
158+ }
159+ } )
160+ . map ( |( p, fc) | ( Arc :: new ( p) , Arc :: new ( fc) ) )
161+ . collect :: < IndexMap < _ , _ > > ( ) ;
158162 if found_err {
159163 Err ( AlreadyReportedToCommandline )
160164 } else {
@@ -350,7 +354,7 @@ fn run(cli: Cli) -> ExitCode {
350354 for ( path, file) in meta_files_by_path {
351355 let File { properties, tests } = file;
352356
353- let file_rel_path = path. strip_prefix ( & gecko_checkout ) . unwrap ( ) ;
357+ let file_rel_path = path. strip_prefix ( & checkout ) . unwrap ( ) ;
354358
355359 file_props_by_file. insert (
356360 Utf8PathBuf :: from ( file_rel_path. to_str ( ) . unwrap ( ) ) ,
@@ -363,7 +367,7 @@ fn run(cli: Cli) -> ExitCode {
363367 subtests,
364368 } = test;
365369
366- let test_path = TestPath :: from_fx_metadata_test ( file_rel_path, & name) . unwrap ( ) ;
370+ let test_path = TestPath :: from_metadata_test ( file_rel_path, & name) . unwrap ( ) ;
367371
368372 let freak_out_do_nothing = |what : & dyn Display | {
369373 log:: error!( "hoo boy, not sure what to do yet: {what}" )
@@ -476,7 +480,7 @@ fn run(cli: Cli) -> ExitCode {
476480 for entry in entries {
477481 let TestExecutionEntry { test_name, result } = entry;
478482
479- let test_path = TestPath :: from_execution_report ( & test_name) . unwrap ( ) ;
483+ let test_path = TestPath :: from_execution_report ( & test_name, browser ) . unwrap ( ) ;
480484 let TestEntry {
481485 entry : test_entry,
482486 subtests : subtest_entries,
@@ -721,8 +725,8 @@ fn run(cli: Cli) -> ExitCode {
721725 let mut files = BTreeMap :: < PathBuf , File > :: new ( ) ;
722726 for ( test_path, ( properties, subtests) ) in recombined_tests_iter {
723727 let name = test_path. test_name ( ) . to_string ( ) ;
724- let rel_path = Utf8PathBuf :: from ( test_path. rel_metadata_path_fx ( ) . to_string ( ) ) ;
725- let path = gecko_checkout . join ( & rel_path) ;
728+ let rel_path = Utf8PathBuf :: from ( test_path. rel_metadata_path ( ) . to_string ( ) ) ;
729+ let path = checkout . join ( & rel_path) ;
726730 let file = files. entry ( path) . or_insert_with ( || File {
727731 properties : file_props_by_file
728732 . get ( & rel_path)
@@ -855,11 +859,11 @@ fn run(cli: Cli) -> ExitCode {
855859 properties : _,
856860 tests,
857861 } ) => Some ( tests. into_iter ( ) . map ( {
858- let gecko_checkout = & gecko_checkout ;
862+ let checkout = & checkout ;
859863 move |( name, inner) | {
860864 let SectionHeader ( name) = & name;
861- let test_path = TestPath :: from_fx_metadata_test (
862- path. strip_prefix ( gecko_checkout ) . unwrap ( ) ,
865+ let test_path = TestPath :: from_metadata_test (
866+ path. strip_prefix ( checkout ) . unwrap ( ) ,
863867 name,
864868 )
865869 . unwrap ( ) ;
@@ -1415,20 +1419,20 @@ fn run(cli: Cli) -> ExitCode {
14151419}
14161420
14171421/// Returns a "naturally" sorted list of files found by searching for `glob_pattern` in `base`.
1418- /// `gecko_checkout ` is stripped as a prefix from the absolute paths recorded into `log` entries
1422+ /// `checkout ` is stripped as a prefix from the absolute paths recorded into `log` entries
14191423/// emitted by this function.
14201424///
14211425/// # Returns
14221426///
1423- /// An iterator over [`Result`]s containing either a Gecko file's path and contents as a UTF-8
1427+ /// An iterator over [`Result`]s containing either a checkout file's path and contents as a UTF-8
14241428/// string, or the sentinel of an error encountered for the same file that is already reported to
14251429/// the command line.
14261430///
14271431/// # Panics
14281432///
1429- /// This function will panick if `gecko_checkout ` cannot be stripped as a prefix of `base`.
1430- fn read_gecko_files_at (
1431- gecko_checkout : & Path ,
1433+ /// This function will panick if `checkout ` cannot be stripped as a prefix of `base`.
1434+ fn read_files_at (
1435+ checkout : & Path ,
14321436 base : & Path ,
14331437 glob_pattern : & str ,
14341438) -> Result <
@@ -1445,7 +1449,7 @@ fn read_gecko_files_at(
14451449 Err ( e) => {
14461450 let path_disp = e
14471451 . path ( )
1448- . map ( |p| format ! ( " in {}" , p. strip_prefix( gecko_checkout ) . unwrap( ) . display( ) ) ) ;
1452+ . map ( |p| format ! ( " in {}" , p. strip_prefix( checkout ) . unwrap( ) . display( ) ) ) ;
14491453 let path_disp: & dyn Display = match path_disp. as_ref ( ) {
14501454 Some ( disp) => disp,
14511455 None => & "" ,
@@ -1467,7 +1471,7 @@ fn read_gecko_files_at(
14671471 "working with these files: {:#?}" ,
14681472 paths
14691473 . iter( )
1470- . map( |f| f. strip_prefix( gecko_checkout ) . unwrap( ) )
1474+ . map( |f| f. strip_prefix( checkout ) . unwrap( ) )
14711475 . collect:: <std:: collections:: BTreeSet <_>>( )
14721476 ) ;
14731477
0 commit comments