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();