From ffbe504242df255c786a4ea99e0a490000fa7b3a Mon Sep 17 00:00:00 2001 From: Will Lillis Date: Sun, 8 Jun 2025 12:39:55 -0400 Subject: [PATCH] fix(xtask): limit `test` command to a single thread on windows (#4489) (cherry picked from commit e1f6e38b5752214f04300eb3b92f9727c2a14e5e) --- xtask/src/test.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/xtask/src/test.rs b/xtask/src/test.rs index 6378f766..a095de07 100644 --- a/xtask/src/test.rs +++ b/xtask/src/test.rs @@ -65,13 +65,17 @@ pub fn run(args: &Test) -> Result<()> { } if args.g { - let cargo_cmd = Command::new("cargo") + let mut cargo_cmd = Command::new("cargo"); + cargo_cmd .arg("test") .arg(test_flags) .arg("--no-run") - .arg("--message-format=json") - .stdout(Stdio::piped()) - .spawn()?; + .arg("--message-format=json"); + + #[cfg(target_os = "windows")] + cargo_cmd.arg("--").arg("--test-threads=1"); + + let cargo_cmd = cargo_cmd.stdout(Stdio::piped()).spawn()?; let jq_cmd = Command::new("jq") .arg("-rs") @@ -97,8 +101,15 @@ pub fn run(args: &Test) -> Result<()> { cargo_cmd.arg(test_flags); } cargo_cmd.args(&args.args); + + #[cfg(target_os = "windows")] + cargo_cmd.arg("--").arg("--test-threads=1"); + if args.nocapture { - cargo_cmd.arg("--").arg("--nocapture"); + #[cfg(not(target_os = "windows"))] + cargo_cmd.arg("--"); + + cargo_cmd.arg("--nocapture"); } bail_on_err( &cargo_cmd.spawn()?.wait_with_output()?,