Skip to content

Commit 289ecee

Browse files
sagudevErichDonGubler
authored andcommitted
Add servo as browser option
1 parent a07bf95 commit 289ecee

2 files changed

Lines changed: 193 additions & 78 deletions

File tree

moz-webgpu-cts/src/main.rs

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use joinery::JoinableIterator;
4040
use miette::{miette, Diagnostic, IntoDiagnostic, NamedSource, Report, SourceSpan, WrapErr};
4141
use path_dsl::path;
4242
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
43+
use shared::Browser;
4344
use wax::Glob;
4445
use whippit::{
4546
metadata::SectionHeader,
@@ -51,8 +52,10 @@ use whippit::{
5152
#[derive(Debug, Parser)]
5253
#[command(about, version)]
5354
struct 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
}
@@ -131,14 +134,12 @@ fn main() -> ExitCode {
131134

132135
fn run(cli: Cli) -> ExitCode {
133136
let Cli {
134-
gecko_checkout,
137+
browser,
138+
checkout,
135139
subcommand,
136140
} = cli;
137141

138-
let gecko_checkout = match gecko_checkout
139-
.map(Ok)
140-
.unwrap_or_else(search_for_moz_central_ckt)
141-
{
142+
let checkout = match checkout.map(Ok).unwrap_or_else(search_for_moz_central_ckt) {
142143
Ok(ckt_path) => ckt_path,
143144
Err(AlreadyReportedToCommandline) => return ExitCode::FAILURE,
144145
};
@@ -244,7 +245,7 @@ fn run(cli: Cli) -> ExitCode {
244245
log::trace!("working with the following WPT report files: {exec_report_paths:#?}");
245246
log::info!("working with {} WPT report files", exec_report_paths.len());
246247

247-
let meta_files_by_path = match read_and_parse_all_metadata(&gecko_checkout)
248+
let meta_files_by_path = match read_and_parse_all_metadata(browser, &checkout)
248249
.collect::<Result<IndexMap<_, _>, _>>()
249250
{
250251
Ok(paths) => paths,
@@ -276,7 +277,7 @@ fn run(cli: Cli) -> ExitCode {
276277
for (path, file) in meta_files_by_path {
277278
let File { properties, tests } = file;
278279

279-
let file_rel_path = path.strip_prefix(&gecko_checkout).unwrap();
280+
let file_rel_path = path.strip_prefix(&checkout).unwrap();
280281

281282
file_props_by_file.insert(
282283
Utf8PathBuf::from(file_rel_path.to_str().unwrap()),
@@ -289,7 +290,8 @@ fn run(cli: Cli) -> ExitCode {
289290
subtests,
290291
} = test;
291292

292-
let test_path = TestPath::from_fx_metadata_test(file_rel_path, &name).unwrap();
293+
let test_path =
294+
TestPath::from_metadata_test(browser, file_rel_path, &name).unwrap();
293295

294296
let freak_out_do_nothing = |what: &dyn Display| {
295297
log::error!("hoo boy, not sure what to do yet: {what}")
@@ -402,7 +404,7 @@ fn run(cli: Cli) -> ExitCode {
402404
for entry in entries {
403405
let TestExecutionEntry { test_name, result } = entry;
404406

405-
let test_path = TestPath::from_execution_report(&test_name).unwrap();
407+
let test_path = TestPath::from_execution_report(browser, &test_name).unwrap();
406408
let TestEntry {
407409
entry: test_entry,
408410
subtests: subtest_entries,
@@ -682,8 +684,8 @@ fn run(cli: Cli) -> ExitCode {
682684
let mut files = BTreeMap::<PathBuf, File>::new();
683685
for (test_path, (properties, subtests)) in recombined_tests_iter {
684686
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);
687+
let rel_path = Utf8PathBuf::from(test_path.rel_metadata_path().to_string());
688+
let path = checkout.join(&rel_path);
687689
let file = files.entry(path).or_insert_with(|| File {
688690
properties: file_props_by_file
689691
.get(&rel_path)
@@ -751,7 +753,7 @@ fn run(cli: Cli) -> ExitCode {
751753
}
752754
Subcommand::Fixup => {
753755
log::info!("fixing up metadata in-place…");
754-
let err_found = read_and_parse_all_metadata(&gecko_checkout)
756+
let err_found = read_and_parse_all_metadata(browser, &checkout)
755757
.map(|res| {
756758
res.and_then(|(path, mut file)| {
757759
for test in file.tests.values_mut() {
@@ -789,7 +791,7 @@ fn run(cli: Cli) -> ExitCode {
789791
inner: Test,
790792
}
791793
let mut err_found = false;
792-
let tests_by_name = read_and_parse_all_metadata(&gecko_checkout)
794+
let tests_by_name = read_and_parse_all_metadata(browser, &checkout)
793795
.map_ok(
794796
|(
795797
path,
@@ -799,11 +801,12 @@ fn run(cli: Cli) -> ExitCode {
799801
},
800802
)| {
801803
tests.into_iter().map({
802-
let gecko_checkout = &gecko_checkout;
804+
let checkout = &checkout;
803805
move |(name, inner)| {
804806
let SectionHeader(name) = &name;
805-
let test_path = TestPath::from_fx_metadata_test(
806-
path.strip_prefix(gecko_checkout).unwrap(),
807+
let test_path = TestPath::from_metadata_test(
808+
browser,
809+
path.strip_prefix(checkout).unwrap(),
807810
name,
808811
)
809812
.unwrap();
@@ -1353,13 +1356,17 @@ fn run(cli: Cli) -> ExitCode {
13531356
}
13541357

13551358
fn read_and_parse_all_metadata(
1356-
gecko_checkout: &Path,
1359+
browser: Browser,
1360+
checkout: &Path,
13571361
) -> 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");
1362+
let webgpu_cts_meta_parent_dir = match browser {
1363+
Browser::Firefox => {
1364+
path!(&checkout | "testing" | "web-platform" | "mozilla" | "meta" | "webgpu")
1365+
}
1366+
Browser::Servo => path!(&checkout | "tests" | "wpt" | "webgpu" | "meta" | "webgpu"),
1367+
};
13601368

1361-
let raw_metadata_files =
1362-
read_gecko_files_at(gecko_checkout, &webgpu_cts_meta_parent_dir, "**/*.ini");
1369+
let raw_metadata_files = read_files_at(checkout, &webgpu_cts_meta_parent_dir, "**/*.ini");
13631370

13641371
let mut started_parsing = false;
13651372
raw_metadata_files.filter_map(move |res| {
@@ -1420,20 +1427,20 @@ fn render_metadata_parse_errors<'a>(
14201427
}
14211428

14221429
/// 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.
1430+
/// `checkout` is stripped as a prefix from the absolute paths recorded into `log` entries emitted
1431+
/// by this function.
14251432
///
14261433
/// # Returns
14271434
///
1428-
/// An iterator over [`Result`]s containing either a Gecko file's path and contents as a UTF-8
1435+
/// An iterator over [`Result`]s containing either a checkout file's path and contents as a UTF-8
14291436
/// string, or the sentinel of an error encountered for the same file that is already reported to
14301437
/// the command line.
14311438
///
14321439
/// # Panics
14331440
///
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,
1441+
/// This function will panick if `checkout` cannot be stripped as a prefix of `base`.
1442+
fn read_files_at(
1443+
checkout: &Path,
14371444
base: &Path,
14381445
glob_pattern: &str,
14391446
) -> impl Iterator<Item = Result<(PathBuf, String), AlreadyReportedToCommandline>> {
@@ -1447,7 +1454,7 @@ fn read_gecko_files_at(
14471454
Err(e) => {
14481455
let path_disp = e
14491456
.path()
1450-
.map(|p| format!(" in {}", p.strip_prefix(gecko_checkout).unwrap().display()));
1457+
.map(|p| format!(" in {}", p.strip_prefix(checkout).unwrap().display()));
14511458
let path_disp: &dyn Display = match path_disp.as_ref() {
14521459
Some(disp) => disp,
14531460
None => &"",
@@ -1469,7 +1476,7 @@ fn read_gecko_files_at(
14691476
"working with these files: {:#?}",
14701477
paths
14711478
.iter()
1472-
.map(|f| f.strip_prefix(gecko_checkout).unwrap())
1479+
.map(|f| f.strip_prefix(checkout).unwrap())
14731480
.collect::<std::collections::BTreeSet<_>>()
14741481
);
14751482

0 commit comments

Comments
 (0)