From fdc4d421e7a0c4c1a8a4eeaf14daf5e47f5ce541 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Sun, 13 Jul 2025 02:48:47 -0400 Subject: [PATCH] Add cargo xtask miri --- xtask/src/main.rs | 10 ++++++++++ xtask/src/miri.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 xtask/src/miri.rs diff --git a/xtask/src/main.rs b/xtask/src/main.rs index f9fa3528c..1c23ceeb7 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -7,6 +7,7 @@ use anyhow::Context; use pico_args::Arguments; mod cts; +mod miri; mod run_wasm; mod test; mod util; @@ -37,6 +38,14 @@ Commands: All extra arguments will be forwarded to cargo-nextest (NOT wgpu-info) + miri + Run all miri-compatible tests under miri. Requires a nightly toolchain + with the x86_64-unknown-linux-gnu target and miri component installed. + + --toolchain The toolchain to use for miri tests. + Must be a nightly toolchain. + Defaults to `nightly`. + vendor-web-sys Re-vendor the WebGPU web-sys bindings. @@ -85,6 +94,7 @@ fn main() -> anyhow::Result { match subcommand.as_deref() { Some("cts") => cts::run_cts(shell, args)?, Some("run-wasm") => run_wasm::run_wasm(shell, args)?, + Some("miri") => miri::run_miri(shell, args)?, Some("test") => test::run_tests(shell, args)?, Some("vendor-web-sys") => vendor_web_sys::run_vendor_web_sys(shell, args)?, Some(subcommand) => { diff --git a/xtask/src/miri.rs b/xtask/src/miri.rs new file mode 100644 index 000000000..572f3da8c --- /dev/null +++ b/xtask/src/miri.rs @@ -0,0 +1,29 @@ +use pico_args::Arguments; +use xshell::Shell; + +pub fn run_miri(shell: Shell, mut args: Arguments) -> anyhow::Result<()> { + let toolchain: String = args + .opt_value_from_str("--toolchain")? + .unwrap_or_else(|| String::from("nightly")); + + shell + .cmd("rustup") + .args([ + "run", + &toolchain, + "cargo", + "miri", + "nextest", + "run", + "--target", + "x86_64-unknown-linux-gnu", + ]) + .env( + "MIRIFLAGS", + "-Zmiri-disable-isolation -Zmiri-deterministic-floats", + ) + .quiet() + .run()?; + + Ok(()) +}