From 35e4b4cc92aca354f5a2a56dbc10362680131607 Mon Sep 17 00:00:00 2001 From: LU XIANGRUI <1078666705@qq.com> Date: Fri, 4 Dec 2026 02:44:31 +0900 Subject: [PATCH] test: fix two Rust tests that fail CI on unrelated changes (#7833) - folders_on_a_share_the_workspace_is_not_on_are_not_looked_up (Windows): Workspace::load now skips a refused project instead of failing, so the test asserts the refusal on normalize_projects and that load leaves the folder out. - restricted_git_does_not_execute_signature_verifier_when_asked_to_verify: the fake verifier reads the payload before exiting, so git no longer dies of SIGPIPE while writing it. Co-authored-by: wildcatDownstairs <26499420+wildcatDownstairs@users.noreply.github.com> --- crates/ide-vcs/src/compare.rs | 4 +++- crates/ide-workspace/src/workspace.rs | 15 +++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/ide-vcs/src/compare.rs b/crates/ide-vcs/src/compare.rs index 1d8af53703..6fa533f0ab 100644 --- a/crates/ide-vcs/src/compare.rs +++ b/crates/ide-vcs/src/compare.rs @@ -692,9 +692,11 @@ mod tests { fn verifier_script(root: &Path) -> (PathBuf, String) { let marker = root.join("executed-marker"); let script = root.join(".git/verifier.sh"); + // Read the payload before exiting: git does not ignore SIGPIPE while it writes to + // `ssh-keygen -Y check-novalidate`, so a verifier that exits first can kill git. std::fs::write( &script, - format!("#!/bin/sh\necho x > '{}'\nexit 1\n", marker.to_str().unwrap().replace('\\', "/")), + format!("#!/bin/sh\necho x > '{}'\ncat >/dev/null\nexit 1\n", marker.to_str().unwrap().replace('\\', "/")), ) .unwrap(); #[cfg(unix)] diff --git a/crates/ide-workspace/src/workspace.rs b/crates/ide-workspace/src/workspace.rs index 483e2bb30d..30399992ba 100644 --- a/crates/ide-workspace/src/workspace.rs +++ b/crates/ide-workspace/src/workspace.rs @@ -320,15 +320,18 @@ mod tests { write(&root, &[&root, &local.join("member")]); assert_eq!(Workspace::load(&root).unwrap().unwrap().projects, [root.clone(), local.join("member")]); - write(&root, &[&root, &share.join("member")]); - let error = Workspace::load(&root).unwrap_err(); - assert!(error.message.starts_with(REFUSED), "{}", error.message); + // Opening skips a refused folder; the error says it was refused before being looked up. + let refused = |projects: Vec| { + write(&root, &projects.iter().map(PathBuf::as_path).collect::>()); + let error = normalize_projects(&root, projects).unwrap_err(); + assert!(error.message.starts_with(REFUSED), "{}", error.message); + assert_eq!(Workspace::load(&root).unwrap().unwrap().projects, std::slice::from_ref(&root)); + }; + refused(vec![root.clone(), share.join("member")]); // A linked folder's own workspace file names its primary folder. write(&root.join("sub"), &[&share.join("member")]); - write(&root, &[&root, Path::new("sub")]); - let error = Workspace::load(&root).unwrap_err(); - assert!(error.message.starts_with(REFUSED), "{}", error.message); + refused(vec![root.clone(), PathBuf::from("sub")]); // A workspace that is on the share links that share's folders. std::fs::remove_file(root.join("sub").join(FILE)).unwrap();