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 <[email protected]>
Цей коміт міститься в:
LU XIANGRUIтаwildcatDownstairs authored and GitHub committed 2026-12-04 01:44:31 +08:00
1 джерело f1876f1260
коміт 35e4b4cc92
2 files changed
+12 -7

No files matched your search

+3 -1
Переглянути файл
@@ -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)]
+9 -6
Переглянути файл
@@ -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<PathBuf>| {
write(&root, &projects.iter().map(PathBuf::as_path).collect::<Vec<_>>());
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();