Symptom
Under uv run cargo test --workspace on Windows, handlers::emulator::tests::* tests that use test_process_command() occasionally fail with:
```
thread 'handlers::emulator::tests::run_avr8js_headless_captures_stdout' panicked at crates\fbuild-daemon\src\handlers\emulator.rs:2523:10:
called `Result::unwrap()` on an `Err` value: DeployFailed("failed to launch QEMU at powershell: program not found")
```
- Observed at least twice this session (different tests each time: once
is_qemu_supported_esp32_mcu_rejects_unsupported, once run_avr8js_headless_captures_stdout).
- Always passes when re-run in isolation or with a smaller test subset.
- Specifically triggers under full-workspace concurrent load where many tests spawn subprocesses in parallel.
Root cause
crates/fbuild-daemon/src/handlers/emulator.rs:2291 — test_process_command() returns PathBuf::from(\"powershell\") on Windows, a bare basename. Command::spawn() then relies on Windows executable-search semantics (SearchPathW plus Rust's own resolution wrapper) to find powershell.exe. Under concurrent load — many tests creating/deleting tempdirs, changing process state — this resolution occasionally fails and CreateProcessW returns ERROR_FILE_NOT_FOUND ("program not found").
Fix
Use an absolute path to PowerShell in the test harness. %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe exists on every Windows install since Vista and is not subject to PATH races.
```rust
#[cfg(windows)]
{
let system_root = std::env::var("SystemRoot").unwrap_or_else(|_| "C:\Windows".to_string());
let exe = PathBuf::from(system_root).join(r"System32\WindowsPowerShell\v1.0\powershell.exe");
(exe, vec![ /* unchanged args */ ])
}
```
Acceptance
Related
Symptom
Under
uv run cargo test --workspaceon Windows,handlers::emulator::tests::*tests that usetest_process_command()occasionally fail with:```
thread 'handlers::emulator::tests::run_avr8js_headless_captures_stdout' panicked at crates\fbuild-daemon\src\handlers\emulator.rs:2523:10:
called `Result::unwrap()` on an `Err` value: DeployFailed("failed to launch QEMU at powershell: program not found")
```
is_qemu_supported_esp32_mcu_rejects_unsupported, oncerun_avr8js_headless_captures_stdout).Root cause
crates/fbuild-daemon/src/handlers/emulator.rs:2291—test_process_command()returnsPathBuf::from(\"powershell\")on Windows, a bare basename.Command::spawn()then relies on Windows executable-search semantics (SearchPathWplus Rust's own resolution wrapper) to findpowershell.exe. Under concurrent load — many tests creating/deleting tempdirs, changing process state — this resolution occasionally fails andCreateProcessWreturnsERROR_FILE_NOT_FOUND("program not found").Fix
Use an absolute path to PowerShell in the test harness.
%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exeexists on every Windows install since Vista and is not subject to PATH races.```rust
#[cfg(windows)]
{
let system_root = std::env::var("SystemRoot").unwrap_or_else(|_| "C:\Windows".to_string());
let exe = PathBuf::from(system_root).join(r"System32\WindowsPowerShell\v1.0\powershell.exe");
(exe, vec![ /* unchanged args */ ])
}
```
Acceptance
uv run cargo test --workspace5× consecutively on Windows without flakes inhandlers::emulator::tests.Related
Command::spawn; this is the same class of problem (Ruststd::process::Commandhas Windows-specific footguns).