Tweaks to CTS xtask, useful when running a modified CTS. (#7737)

This commit is contained in:
Andy Leiserson 2025-05-30 15:09:32 -07:00 committed by GitHub
parent a04085c5e4
commit ffd5b9aeea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 11 deletions

View File

@ -1,4 +1,4 @@
use anyhow::Context; use anyhow::{bail, Context};
use pico_args::Arguments; use pico_args::Arguments;
use std::ffi::OsString; use std::ffi::OsString;
use xshell::Shell; use xshell::Shell;
@ -16,8 +16,9 @@ const CTS_GIT_URL: &str = "https://github.com/gpuweb/cts.git";
const CTS_DEFAULT_TEST_LIST: &str = "cts_runner/test.lst"; const CTS_DEFAULT_TEST_LIST: &str = "cts_runner/test.lst";
pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> { pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
let mut list_files = Vec::<OsString>::new(); let skip_checkout = args.contains("--skip-checkout");
let mut list_files = Vec::<OsString>::new();
while let Some(file) = args.opt_value_from_str("-f")? { while let Some(file) = args.opt_value_from_str("-f")? {
list_files.push(file); list_files.push(file);
} }
@ -37,6 +38,8 @@ pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
})) }))
} }
let wgpu_cargo_toml = shell.current_dir().join("Cargo.toml").canonicalize()?;
let cts_revision = shell let cts_revision = shell
.read_file(CTS_REVISION_PATH) .read_file(CTS_REVISION_PATH)
.context(format!( .context(format!(
@ -46,6 +49,9 @@ pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
.to_string(); .to_string();
if !shell.path_exists(CTS_CHECKOUT_PATH) { if !shell.path_exists(CTS_CHECKOUT_PATH) {
if skip_checkout {
bail!("Skipping CTS checkout doesn't make sense when CTS is not present");
}
log::info!("Cloning CTS"); log::info!("Cloning CTS");
shell shell
.cmd("git") .cmd("git")
@ -57,6 +63,7 @@ pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
shell.change_dir(CTS_CHECKOUT_PATH); shell.change_dir(CTS_CHECKOUT_PATH);
if !skip_checkout {
log::info!("Checking out CTS"); log::info!("Checking out CTS");
shell shell
.cmd("git") .cmd("git")
@ -64,13 +71,16 @@ pub fn run_cts(shell: Shell, mut args: Arguments) -> anyhow::Result<()> {
.quiet() .quiet()
.run() .run()
.context("Failed to check out CTS")?; .context("Failed to check out CTS")?;
} else {
log::info!("Skipping CTS checkout because --skip-checkout was specified");
}
log::info!("Running CTS"); log::info!("Running CTS");
for test in &tests { for test in &tests {
shell shell
.cmd("cargo") .cmd("cargo")
.args(["run"]) .args(["run"])
.args(["--manifest-path", "../Cargo.toml"]) .args(["--manifest-path".as_ref(), wgpu_cargo_toml.as_os_str()])
.args(["-p", "cts_runner"]) .args(["-p", "cts_runner"])
.args(["--bin", "cts_runner"]) .args(["--bin", "cts_runner"])
.args(["--", "./tools/run_deno", "--verbose"]) .args(["--", "./tools/run_deno", "--verbose"])

View File

@ -16,9 +16,12 @@ const HELP: &str = "\
Usage: xtask <COMMAND> Usage: xtask <COMMAND>
Commands: Commands:
cts [<test selector> | -f <test list file>]... cts [--skip-checkout] [<test selector> | -f <test list file>]...
Check out, build, and run CTS tests Check out, build, and run CTS tests
--skip-checkout Don't check out the pinned CTS version, use whatever is
already checked out.
run-wasm run-wasm
Build and run web examples Build and run web examples