From 7eee1fd13f49d44c07e66607189cc2eb84e53683 Mon Sep 17 00:00:00 2001 From: BFlat Date: Wed, 4 Nov 2026 08:46:46 +0700 Subject: [PATCH] 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. --- crates/engine/src/workspace.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/workspace.rs b/crates/engine/src/workspace.rs index 5ec1e69e..1cdfe0f2 100644 --- a/crates/engine/src/workspace.rs +++ b/crates/engine/src/workspace.rs @@ -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:?}");