@@ -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 ,
@@ -51,29 +52,31 @@ use whippit::{
5152#[ derive( Debug , Parser ) ]
5253#[ command( about, version) ]
5354struct Cli {
54- #[ clap( long) ]
55- gecko_checkout : Option < PathBuf > ,
55+ #[ clap( long, alias = "gecko-checkout" ) ]
56+ checkout : Option < PathBuf > ,
57+ #[ clap( value_enum, long, default_value = "firefox" ) ]
58+ browser : Browser ,
5659 #[ clap( subcommand) ]
5760 subcommand : Subcommand ,
5861}
5962
6063#[ derive( Debug , Parser ) ]
6164enum Subcommand {
6265 /// Adjust expected test outcomes in metadata, optionally using `wptreport.json` reports from
63- /// CI runs covering Firefox 's implementation of WebGPU.
66+ /// CI runs covering your browser 's implementation of WebGPU.
6467 ///
65- /// As Firefox 's behavior changes, one generally expects CTS test outcomes to change. When you
66- /// are testing your own changes in CI, you can use this subcommand to update expected outcomes
67- /// automatically with the following steps:
68+ /// As your browser 's behavior changes, one generally expects CTS test outcomes to change. When
69+ /// you are testing your own changes in CI, you can use this subcommand to update expected
70+ /// outcomes automatically with the following steps:
6871 ///
69- /// 1. Run `moz-webgpu-cts update-expected --preset=new-fx …` against the first complete set of
70- /// reports you gather from CI with your new Firefox build. This will adjust for new
72+ /// 1. Run `moz-webgpu-cts update-expected --preset=new-build …` against the first complete set
73+ /// of reports you gather from CI with your new browser build. This will adjust for new
7174 /// permanent outcomes, and may capture some (but not all) intermittent outcomes.
7275 ///
7376 /// 2. There may still exist intermittent issues that you do not discover in CI run(s) from the
7477 /// previous step. As you discover them in further CI runs on the same build of Firefox,
7578 /// adjust expected outcomes to match by running `moz-webgpu-cts update-expected
76- /// --preset=same-fx …` against the runs' new reports. Repeat as necessary.
79+ /// --preset=same-build …` against the runs' new reports. Repeat as necessary.
7780 ///
7881 /// With both steps, you may delete the local copies of these reports after being processed
7982 /// with `update-expected`. You should not need to re-process them unless you have made an
@@ -107,9 +110,11 @@ enum Subcommand {
107110enum ReportProcessingPreset {
108111 /// alias: `new-fx`
109112 #[ value( alias( "new-fx" ) ) ]
113+ #[ value( alias( "new-build" ) ) ]
110114 ResetContradictory ,
111115 /// alias: `same-fx`
112116 #[ value( alias( "same-fx" ) ) ]
117+ #[ value( alias( "same-build" ) ) ]
113118 Merge ,
114119 ResetAll ,
115120}
@@ -131,14 +136,12 @@ fn main() -> ExitCode {
131136
132137fn run ( cli : Cli ) -> ExitCode {
133138 let Cli {
134- gecko_checkout,
139+ browser,
140+ checkout,
135141 subcommand,
136142 } = cli;
137143
138- let gecko_checkout = match gecko_checkout
139- . map ( Ok )
140- . unwrap_or_else ( search_for_moz_central_ckt)
141- {
144+ let checkout = match checkout. map ( Ok ) . unwrap_or_else ( search_for_repo_root) {
142145 Ok ( ckt_path) => ckt_path,
143146 Err ( AlreadyReportedToCommandline ) => return ExitCode :: FAILURE ,
144147 } ;
@@ -244,7 +247,7 @@ fn run(cli: Cli) -> ExitCode {
244247 log:: trace!( "working with the following WPT report files: {exec_report_paths:#?}" ) ;
245248 log:: info!( "working with {} WPT report files" , exec_report_paths. len( ) ) ;
246249
247- let meta_files_by_path = match read_and_parse_all_metadata ( & gecko_checkout )
250+ let meta_files_by_path = match read_and_parse_all_metadata ( browser , & checkout )
248251 . collect :: < Result < IndexMap < _ , _ > , _ > > ( )
249252 {
250253 Ok ( paths) => paths,
@@ -276,7 +279,7 @@ fn run(cli: Cli) -> ExitCode {
276279 for ( path, file) in meta_files_by_path {
277280 let File { properties, tests } = file;
278281
279- let file_rel_path = path. strip_prefix ( & gecko_checkout ) . unwrap ( ) ;
282+ let file_rel_path = path. strip_prefix ( & checkout ) . unwrap ( ) ;
280283
281284 file_props_by_file. insert (
282285 Utf8PathBuf :: from ( file_rel_path. to_str ( ) . unwrap ( ) ) ,
@@ -289,7 +292,8 @@ fn run(cli: Cli) -> ExitCode {
289292 subtests,
290293 } = test;
291294
292- let test_path = TestPath :: from_fx_metadata_test ( file_rel_path, & name) . unwrap ( ) ;
295+ let test_path =
296+ TestPath :: from_metadata_test ( browser, file_rel_path, & name) . unwrap ( ) ;
293297
294298 let freak_out_do_nothing = |what : & dyn Display | {
295299 log:: error!( "hoo boy, not sure what to do yet: {what}" )
@@ -402,7 +406,7 @@ fn run(cli: Cli) -> ExitCode {
402406 for entry in entries {
403407 let TestExecutionEntry { test_name, result } = entry;
404408
405- let test_path = TestPath :: from_execution_report ( & test_name) . unwrap ( ) ;
409+ let test_path = TestPath :: from_execution_report ( browser , & test_name) . unwrap ( ) ;
406410 let TestEntry {
407411 entry : test_entry,
408412 subtests : subtest_entries,
@@ -682,8 +686,8 @@ fn run(cli: Cli) -> ExitCode {
682686 let mut files = BTreeMap :: < PathBuf , File > :: new ( ) ;
683687 for ( test_path, ( properties, subtests) ) in recombined_tests_iter {
684688 let name = test_path. test_name ( ) . to_string ( ) ;
685- let rel_path = Utf8PathBuf :: from ( test_path. rel_metadata_path_fx ( ) . to_string ( ) ) ;
686- let path = gecko_checkout . join ( & rel_path) ;
689+ let rel_path = Utf8PathBuf :: from ( test_path. rel_metadata_path ( ) . to_string ( ) ) ;
690+ let path = checkout . join ( & rel_path) ;
687691 let file = files. entry ( path) . or_insert_with ( || File {
688692 properties : file_props_by_file
689693 . get ( & rel_path)
@@ -751,7 +755,7 @@ fn run(cli: Cli) -> ExitCode {
751755 }
752756 Subcommand :: Fixup => {
753757 log:: info!( "fixing up metadata in-place…" ) ;
754- let err_found = read_and_parse_all_metadata ( & gecko_checkout )
758+ let err_found = read_and_parse_all_metadata ( browser , & checkout )
755759 . map ( |res| {
756760 res. and_then ( |( path, mut file) | {
757761 for test in file. tests . values_mut ( ) {
@@ -789,7 +793,7 @@ fn run(cli: Cli) -> ExitCode {
789793 inner : Test ,
790794 }
791795 let mut err_found = false ;
792- let tests_by_name = read_and_parse_all_metadata ( & gecko_checkout )
796+ let tests_by_name = read_and_parse_all_metadata ( browser , & checkout )
793797 . map_ok (
794798 |(
795799 path,
@@ -799,11 +803,12 @@ fn run(cli: Cli) -> ExitCode {
799803 } ,
800804 ) | {
801805 tests. into_iter ( ) . map ( {
802- let gecko_checkout = & gecko_checkout ;
806+ let checkout = & checkout ;
803807 move |( name, inner) | {
804808 let SectionHeader ( name) = & name;
805- let test_path = TestPath :: from_fx_metadata_test (
806- path. strip_prefix ( gecko_checkout) . unwrap ( ) ,
809+ let test_path = TestPath :: from_metadata_test (
810+ browser,
811+ path. strip_prefix ( checkout) . unwrap ( ) ,
807812 name,
808813 )
809814 . unwrap ( ) ;
@@ -1353,13 +1358,17 @@ fn run(cli: Cli) -> ExitCode {
13531358}
13541359
13551360fn read_and_parse_all_metadata (
1356- gecko_checkout : & Path ,
1361+ browser : Browser ,
1362+ checkout : & Path ,
13571363) -> impl Iterator < Item = Result < ( Arc < PathBuf > , metadata:: File ) , AlreadyReportedToCommandline > > {
1358- let webgpu_cts_meta_parent_dir =
1359- path ! ( gecko_checkout | "testing" | "web-platform" | "mozilla" | "meta" | "webgpu" ) ;
1364+ let webgpu_cts_meta_parent_dir = match browser {
1365+ Browser :: Firefox => {
1366+ path ! ( & checkout | "testing" | "web-platform" | "mozilla" | "meta" | "webgpu" )
1367+ }
1368+ Browser :: Servo => path ! ( & checkout | "tests" | "wpt" | "webgpu" | "meta" | "webgpu" ) ,
1369+ } ;
13601370
1361- let raw_metadata_files =
1362- read_gecko_files_at ( gecko_checkout, & webgpu_cts_meta_parent_dir, "**/*.ini" ) ;
1371+ let raw_metadata_files = read_files_at ( checkout, & webgpu_cts_meta_parent_dir, "**/*.ini" ) ;
13631372
13641373 let mut started_parsing = false ;
13651374 raw_metadata_files. filter_map ( move |res| {
@@ -1420,20 +1429,20 @@ fn render_metadata_parse_errors<'a>(
14201429}
14211430
14221431/// Returns a "naturally" sorted list of files found by searching for `glob_pattern` in `base`.
1423- /// `gecko_checkout ` is stripped as a prefix from the absolute paths recorded into `log` entries
1424- /// emitted by this function.
1432+ /// `checkout ` is stripped as a prefix from the absolute paths recorded into `log` entries emitted
1433+ /// by this function.
14251434///
14261435/// # Returns
14271436///
1428- /// An iterator over [`Result`]s containing either a Gecko file's path and contents as a UTF-8
1437+ /// An iterator over [`Result`]s containing either a checkout file's path and contents as a UTF-8
14291438/// string, or the sentinel of an error encountered for the same file that is already reported to
14301439/// the command line.
14311440///
14321441/// # Panics
14331442///
1434- /// This function will panick if `gecko_checkout ` cannot be stripped as a prefix of `base`.
1435- fn read_gecko_files_at (
1436- gecko_checkout : & Path ,
1443+ /// This function will panick if `checkout ` cannot be stripped as a prefix of `base`.
1444+ fn read_files_at (
1445+ checkout : & Path ,
14371446 base : & Path ,
14381447 glob_pattern : & str ,
14391448) -> impl Iterator < Item = Result < ( PathBuf , String ) , AlreadyReportedToCommandline > > {
@@ -1447,7 +1456,7 @@ fn read_gecko_files_at(
14471456 Err ( e) => {
14481457 let path_disp = e
14491458 . path ( )
1450- . map ( |p| format ! ( " in {}" , p. strip_prefix( gecko_checkout ) . unwrap( ) . display( ) ) ) ;
1459+ . map ( |p| format ! ( " in {}" , p. strip_prefix( checkout ) . unwrap( ) . display( ) ) ) ;
14511460 let path_disp: & dyn Display = match path_disp. as_ref ( ) {
14521461 Some ( disp) => disp,
14531462 None => & "" ,
@@ -1469,7 +1478,7 @@ fn read_gecko_files_at(
14691478 "working with these files: {:#?}" ,
14701479 paths
14711480 . iter( )
1472- . map( |f| f. strip_prefix( gecko_checkout ) . unwrap( ) )
1481+ . map( |f| f. strip_prefix( checkout ) . unwrap( ) )
14731482 . collect:: <std:: collections:: BTreeSet <_>>( )
14741483 ) ;
14751484
@@ -1494,19 +1503,19 @@ fn read_gecko_files_at(
14941503 . chain ( file_read_iter. into_iter ( ) . flatten ( ) )
14951504}
14961505
1497- /// Search for a `mozilla-central` checkout either via Mercurial or Git, iterating from the CWD to
1506+ /// Search for source code repository root either via Mercurial or Git, iterating from the CWD to
14981507/// its parent directories.
14991508///
15001509/// This function reports to `log` automatically, so no meaningful [`Err`] value is returned.
1501- fn search_for_moz_central_ckt ( ) -> Result < PathBuf , AlreadyReportedToCommandline > {
1510+ fn search_for_repo_root ( ) -> Result < PathBuf , AlreadyReportedToCommandline > {
15021511 use lets_find_up:: { find_up_with, FindUpKind , FindUpOptions } ;
15031512
15041513 let find_up_opts = || FindUpOptions {
15051514 cwd : Path :: new ( "." ) ,
15061515 kind : FindUpKind :: Dir ,
15071516 } ;
15081517 let find_up = |repo_tech_name, root_dir_name| {
1509- log:: debug!( "searching for {repo_tech_name} checkout of `mozilla-central` …" ) ;
1518+ log:: debug!( "searching for {repo_tech_name} repository root …" ) ;
15101519 let err = || {
15111520 miette ! (
15121521 "failed to find a {} repository ({:?}) in {}" ,
@@ -1533,13 +1542,13 @@ fn search_for_moz_central_ckt() -> Result<PathBuf, AlreadyReportedToCommandline>
15331542 Err ( e2) => {
15341543 log:: warn!( "{e:?}" ) ;
15351544 log:: warn!( "{e2:?}" ) ;
1536- log:: error!( "failed to find a Gecko repository root" ) ;
1545+ log:: error!( "failed to automatically find a repository root" ) ;
15371546 Err ( AlreadyReportedToCommandline )
15381547 }
15391548 } ) ?;
15401549
15411550 log:: info!(
1542- "detected Gecko repository root at {}" ,
1551+ "detected repository root at {}" ,
15431552 gecko_source_root. display( )
15441553 ) ;
15451554
0 commit comments