Skip to content

Commit 752be42

Browse files
committed
fix(test): redact cwd path in ParsePlanRequest on Windows
The previous attempt unconditionally replaced `\\` with `\` on Windows to unescape Debug-formatted paths, but this also collapsed the `\\?\` verbatim prefix in Display-formatted paths used by other errors (e.g. `ambiguous package name`), breaking those snapshots. Instead, fix the root cause: format `cwd` with Display (`{cwd}`) rather than Debug (`{cwd:?}`) in `ParsePlanRequest`. Display uses `Path::display()` which emits raw backslashes on Windows, so the existing raw `workspace_root_str` redaction works uniformly. Keep the surrounding double quotes explicitly in the format string so the existing `"<workspace>/"` snapshot stays exactly as-is. Revert the test-side `\\` → `\` unescape now that it is no longer needed and was breaking previously passing tests. https://claude.ai/code/session_01RyEZx6J2a3SodaA5fzrwk6
1 parent e592bf1 commit 752be42

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

crates/vite_task_plan/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub enum Error {
119119
#[error(transparent)]
120120
TaskRecursionDetected(#[from] TaskRecursionError),
121121

122-
#[error("Invalid vite task command: {program} with args {args:?} under cwd {cwd:?}")]
122+
#[error("Invalid vite task command: {program} with args {args:?} under cwd \"{cwd}\"")]
123123
ParsePlanRequest {
124124
program: Str,
125125
args: Arc<[Str]>,

crates/vite_task_plan/tests/plan_snapshots/main.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,8 @@ fn run_case_inner(
272272
// and redact workspace paths for snapshot stability.
273273
let anyhow_err: anyhow::Error = err.into();
274274
let err_formatted = vite_str::format!("{anyhow_err:#}");
275-
// On Windows, paths printed via `{path:?}` are Debug-formatted
276-
// with each backslash escaped as `\\`. Unescape them before
277-
// redacting so the raw `workspace_root_str` matches.
278-
let err_str = if cfg!(windows) {
279-
err_formatted.as_str().cow_replace("\\\\", "\\")
280-
} else {
281-
std::borrow::Cow::Borrowed(err_formatted.as_str())
282-
};
283-
let err_str = err_str.as_ref().cow_replace(workspace_root_str, "<workspace>");
275+
let err_str =
276+
err_formatted.as_str().cow_replace(workspace_root_str, "<workspace>");
284277
let err_str = if cfg!(windows) {
285278
err_str.as_ref().cow_replace('\\', "/")
286279
} else {

0 commit comments

Comments
 (0)