From 471bce2bb1418cd82a2b2dbefe5a461e12c1e2dd Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Wed, 2 Dec 2026 18:46:03 +0800 Subject: [PATCH] test: make the Windows Rust job pass again (#7516) git_workflows: the 700 overlong paths of the two command-line batching tests exceeded Windows' 260-char MAX_PATH (Git for Windows enforces it without core.longpaths), so git add failed; on Windows they use shorter names that still overflow its 32,000-char command line. xcode_index: the test formatted a path into buildServer.json, and a Windows path's backslashes made the JSON invalid; it is built with serde_json now. --- crates/ide-run/src/xcode_index.rs | 3 ++- crates/ide-vcs/tests/git_workflows.rs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/ide-run/src/xcode_index.rs b/crates/ide-run/src/xcode_index.rs index e1fbcd845..2e83bd286 100644 --- a/crates/ide-run/src/xcode_index.rs +++ b/crates/ide-run/src/xcode_index.rs @@ -147,8 +147,9 @@ mod tests { let root = tmp.path(); assert_eq!(xcode_build_root(root), None); let dd = root.join("DerivedData/App-abc"); + // Built as JSON, not by formatting: a Windows path's backslashes need escaping. let config = - |kind: &str| format!(r#"{{"name":"xcode build server","kind":"{kind}","build_root":"{}"}}"#, dd.display()); + |kind: &str| serde_json::json!({"name": "xcode build server", "kind": kind, "build_root": dd}).to_string(); std::fs::write(root.join("buildServer.json"), config("manual")).unwrap(); assert_eq!(xcode_build_root(root), None, "a hand-written .compile config"); std::fs::write(root.join("buildServer.json"), r#"{"name":"sourcekit-xcode-bsp","argv":["x"]}"#).unwrap(); diff --git a/crates/ide-vcs/tests/git_workflows.rs b/crates/ide-vcs/tests/git_workflows.rs index 6f1bc76fb..512fd50d3 100644 --- a/crates/ide-vcs/tests/git_workflows.rs +++ b/crates/ide-vcs/tests/git_workflows.rs @@ -3710,11 +3710,18 @@ fn blocked_restore_keeps_the_deletion_record_for_the_next_attempt() { assert!(!fx.exists(".git/openidea-saved-deletions")); } +/// A folder and file name whose 700 paths overflow one command line (32,000 chars on Windows, +/// 120,000 elsewhere), while each absolute path stays within Windows' 260-char `MAX_PATH`, +/// which Git for Windows enforces without `core.longpaths`. +fn overlong_names() -> (String, String) { + if cfg!(windows) { ("f".repeat(40), "n".repeat(60)) } else { ("f".repeat(100), "n".repeat(110)) } +} + #[test] fn pull_keeps_more_deleted_new_files_than_one_command_line_holds_deleted() { let (fx, bare) = Fixture::with_origin(); - let folder = "f".repeat(100); - let paths: Vec = (0..700).map(|i| format!("{folder}/{i:04}-{}.txt", "n".repeat(110))).collect(); + let (folder, name) = overlong_names(); + let paths: Vec = (0..700).map(|i| format!("{folder}/{i:04}-{name}.txt")).collect(); for path in &paths { fx.write(path, "new\n"); } @@ -3763,8 +3770,8 @@ fn deleting_more_added_files_than_one_command_line_holds_drops_them_all() { let fx = Fixture::new(); fx.write("base.txt", "base\n"); fx.commit_all("base"); - let folder = "f".repeat(100); - let paths: Vec = (0..700).map(|i| fx.path(&format!("{folder}/{i:04}-{}.txt", "n".repeat(110)))).collect(); + let (folder, name) = overlong_names(); + let paths: Vec = (0..700).map(|i| fx.path(&format!("{folder}/{i:04}-{name}.txt"))).collect(); for path in &paths { std::fs::create_dir_all(path.parent().unwrap()).unwrap(); std::fs::write(path, "new\n").unwrap();