summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/vendor/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dom/webgpu/tests/cts/vendor/src/main.rs')
-rw-r--r--dom/webgpu/tests/cts/vendor/src/main.rs49
1 files changed, 41 insertions, 8 deletions
diff --git a/dom/webgpu/tests/cts/vendor/src/main.rs b/dom/webgpu/tests/cts/vendor/src/main.rs
index 750b65c62e..1171c90b3a 100644
--- a/dom/webgpu/tests/cts/vendor/src/main.rs
+++ b/dom/webgpu/tests/cts/vendor/src/main.rs
@@ -6,12 +6,13 @@ use std::{
};
use clap::Parser;
+use itertools::Itertools;
use lets_find_up::{find_up_with, FindUpKind, FindUpOptions};
use miette::{bail, ensure, miette, Context, Diagnostic, IntoDiagnostic, Report, SourceSpan};
use regex::Regex;
use crate::{
- fs::{copy_dir, create_dir_all, existing_file, remove_file, FileRoot},
+ fs::{copy_dir, create_dir_all, remove_file, FileRoot},
path::join_path,
process::{which, EasyCommand},
};
@@ -277,13 +278,6 @@ fn run(args: CliArgs) -> miette::Result<()> {
})?;
let cts_https_html_path = out_wpt_dir.child("cts.https.html");
- log::info!("refining the output of {cts_https_html_path} with `npm run gen_wpt_cts_html …`…");
- EasyCommand::new(&npm_bin, |cmd| {
- cmd.args(["run", "gen_wpt_cts_html"]).arg(existing_file(
- &cts_ckt.child("tools/gen_wpt_cfg_unchunked.json"),
- ))
- })
- .spawn()?;
{
let extra_cts_https_html_path = out_wpt_dir.child("cts-chunked2sec.https.html");
@@ -551,6 +545,45 @@ fn run(args: CliArgs) -> miette::Result<()> {
log::info!(" …removing {cts_https_html_path}, now that it's been divided up…");
remove_file(&cts_https_html_path)?;
+ log::info!("moving ready-to-go WPT test files into `cts`…");
+
+ let webgpu_dir = out_wpt_dir.child("webgpu");
+ let ready_to_go_tests = wax::Glob::new("**/*.{html,{any,sub,worker}.js}")
+ .unwrap()
+ .walk(&webgpu_dir)
+ .map_ok(|entry| webgpu_dir.child(entry.into_path()))
+ .collect::<Result<Vec<_>, _>>()
+ .map_err(Report::msg)
+ .wrap_err_with(|| {
+ format!("failed to walk {webgpu_dir} for ready-to-go WPT test files")
+ })?;
+
+ log::trace!(" …will move the following: {ready_to_go_tests:#?}");
+
+ for file in ready_to_go_tests {
+ let path_relative_to_webgpu_dir = file.strip_prefix(&webgpu_dir).unwrap();
+ let dst_path = cts_tests_dir.child(path_relative_to_webgpu_dir);
+ log::trace!("…moving {file} to {dst_path}…");
+ ensure!(
+ !fs::try_exists(&dst_path)?,
+ "internal error: duplicate path found while moving ready-to-go test {} to {}",
+ file,
+ dst_path,
+ );
+ fs::create_dir_all(dst_path.parent().unwrap()).wrap_err_with(|| {
+ format!(
+ concat!(
+ "failed to create destination parent dirs. ",
+ "while recursively moving from {} to {}",
+ ),
+ file, dst_path,
+ )
+ })?;
+ fs::rename(&file, &dst_path)
+ .wrap_err_with(|| format!("failed to move {file} to {dst_path}"))?;
+ }
+ log::debug!(" …finished moving ready-to-go WPT test files");
+
Ok(())
})?;