The pasted-picture test passes when its pastes share a millisecond (#761)

The pasted-picture test accepts a third paste that lands in the same millisecond as the first and takes its freed name, and checks the first paste's content is gone. Test only.
This commit is contained in:
BFlat
2026-11-04 08:46:46 +07:00
committed by GitHub
parent bbc06cb9c1
commit 7eee1fd13f
+3 -1
View File
@@ -1281,7 +1281,9 @@ mod tests {
std::fs::File::options().write(true).open(f).unwrap().set_modified(old).unwrap();
}
let third = save_pasted_picture(dir.path(), 2, 1, vec![0; 8], std::slice::from_ref(&second)).unwrap();
assert!(!p.exists() && second.exists() && third.exists());
// In the same millisecond as the first, the third takes the name its removal freed.
assert!((third == p || !p.exists()) && second.exists() && third.exists());
assert_ne!(std::fs::read(&third).ok(), Some(bytes), "the first paste is gone");
let mut names: Vec<_> = std::fs::read_dir(dir.path()).unwrap().flatten().map(|e| e.file_name()).collect();
names.sort();
assert_eq!(names.len(), 2, "no temp files left behind: {names:?}");