From b322ff2f13eb7bfee2f4001c687dea3369f40499 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 24 Oct 2026 03:19:55 -0700 Subject: [PATCH] CLI tests: the several-roots test uses plain paths, so it passes on Windows cli::mcp_automation_roots_take_several_folders built its folders from std::fs::canonicalize, which returns \\?\C:\... on Windows. The server prints its roots without that prefix (file_access::plain), so the stderr check never matched. The test also sent \\?\ paths with `..` in them, which Windows does not normalize, so that call failed with "cannot resolve" instead of "outside the read roots". A test helper now canonicalizes and strips \\?\ (and \\?\UNC\) on Windows, as file_access::plain does, and the test builds every path from it. On macOS and Linux the paths are unchanged. --- apps/soundcraft-cli/tests/it/cli.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/soundcraft-cli/tests/it/cli.rs b/apps/soundcraft-cli/tests/it/cli.rs index ebc92cc5..2921f4a8 100644 --- a/apps/soundcraft-cli/tests/it/cli.rs +++ b/apps/soundcraft-cli/tests/it/cli.rs @@ -24,6 +24,20 @@ fn tmpdir(tag: &str) -> PathBuf { dir } +/// `path` made absolute with links followed (`/var` becomes `/private/var` on macOS), as the server +/// prints a root: without the `\\?\` prefix that `canonicalize` adds on Windows. +fn resolved(path: &Path) -> PathBuf { + let path = std::fs::canonicalize(path).unwrap(); + if !cfg!(windows) { + return path; + } + let text = path.to_str().unwrap(); + if let Some(rest) = text.strip_prefix(r"\\?\UNC\") { + return PathBuf::from(format!(r"\\{rest}")); + } + text.strip_prefix(r"\\?\").map_or(path.clone(), PathBuf::from) +} + /// Send `calls` (tool name, arguments) to `soundcraft-cli mcp `; returns whether it exited /// cleanly, its stderr, and the stdout lines after `initialize`, one per call. fn mcp_session(args: &[&str], calls: &[(&str, Value)]) -> (bool, String, Vec) { @@ -114,8 +128,7 @@ fn mcp_automation_roots_confine_the_server() { /// the two roots' common parent, `..` out of a root and a link out of one stay refused. #[test] fn mcp_automation_roots_take_several_folders() { - // Resolved, as the server shows the roots (`/var` is `/private/var` on macOS). - let base = std::fs::canonicalize(tmpdir("several")).unwrap(); + let base = resolved(&tmpdir("several")); for d in ["in", "in2", "out", "out2", "outside"] { std::fs::create_dir_all(base.join(d)).unwrap(); }