From 7d8638f854777ece05887560a7dc0a563a0d62d7 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Sat, 10 Oct 2026 17:32:24 -0700 Subject: [PATCH] test(windows): build_watch_parses uses the long temp path On Windows the temp dir can be a short name (C:\Users\RUNNER~1). tsc names its watches by the real (long) path, so the goport_watch edit under the short path reached no watch and build 2 never started. The scratch dir is now canonical without the verbatim prefix, as in multi_program. Co-Authored-By: Claude Opus 5.5 --- crates/ts_goport/tests/build_watch_parses.rs | 22 +++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/ts_goport/tests/build_watch_parses.rs b/crates/ts_goport/tests/build_watch_parses.rs index 1262e8c60..121802e12 100644 --- a/crates/ts_goport/tests/build_watch_parses.rs +++ b/crates/ts_goport/tests/build_watch_parses.rs @@ -367,10 +367,26 @@ fn scratch_dir_in(base: &Path, test: &str) -> PathBuf { std::process::id() )); fs::create_dir(&dir).unwrap_or_else(|error| panic!("create {}: {error}", dir.display())); - if cfg!(windows) { - return dir; + // tsc names the watched directories by the real path, so the test must + // too: on Windows the temp dir can be a short name (`RUNNER~1`), and an + // edit under it then reaches no watch. + let real = fs::canonicalize(&dir).expect("canonical scratch dir"); + // On Windows the real path is verbatim (`\\?\C:\...`), which tsc does not + // take as a cwd. + #[cfg(windows)] + let real = PathBuf::from(unverbatim(&real.to_string_lossy())); + real +} + +/// `text` without the Windows verbatim prefix: `\\?\C:\x` is `C:\x`, and +/// `\\?\UNC\server\share\x` is `\\server\share\x` (the root stays). +#[cfg(windows)] +fn unverbatim(text: &str) -> String { + if let Some(unc) = text.strip_prefix("\\\\?\\UNC\\") { + format!("\\\\{unc}") + } else { + text.strip_prefix("\\\\?\\").unwrap_or(text).to_owned() } - fs::canonicalize(&dir).expect("canonical scratch dir") } fn copy_dir(from: &Path, to: &Path) {