mirror of
https://github.com/storytold/soundcraft.git
synced 2026-10-29 13:06:49 -06:00
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.
This commit is contained in:
@@ -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 <args>`; 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<Value>) {
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user