git.lucas.co / cce-designer
graphic design tool
git clone https://git.lucas.co/cce-designer.git

commit113bac64f5f75321b353a856bb4dde3d3b6a7336
parent6477d79933
authorLucas Galante <[email protected]>
date2026-09-23 12:24
fix: the last two test temp dirs are scoped to the process

Every other test in this file already scopes its `temp_dir()` path with
`std::process::id()`; `cce-designer-test-projects` and
`cce-designer-page-tests` were the two that did not, and shared one fixed
path across every run on the machine.

/tmp is one namespace shared by every user — the point `../cce-compositor/
WORKSPACE.md` makes about `cce_runtime_dir` — so a fixed name is the first
user's to own and the sticky bit denies it to everyone else. Nearer to hand,
two suites running at once is the normal state of this workspace, and they
were sharing a directory.

Found while sweeping the other crates for the hazard that made `cargo test`
rewrite the user's state.kdl. cce-browser has the same pattern in
`session.rs`, also beside siblings that scope theirs; that is its own repo's
to fix.

Co-Authored-By: Claude Opus 5 <[email protected]>

 src/main.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 28298b7..29148fd 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -134,7 +134,9 @@ mod tests {
         let mut state = State::new(false);
         assert_eq!(state.chooser_start_dir(), None, "scratch project must not pin a dir");
 
-        let dir = std::env::temp_dir().join("cce-designer-test-projects").join("gears");
+        let dir = std::env::temp_dir()
+            .join(format!("cce-designer-test-projects-{}", std::process::id()))
+            .join("gears");
         std::fs::create_dir_all(&dir).unwrap();
         state.loaded_project_path = Some(dir.clone());
         assert_eq!(state.chooser_start_dir().as_deref(), dir.parent(),
@@ -6179,7 +6181,8 @@ mod tests {
     #[test]
     fn test_the_png_knows_its_own_physical_size() {
         use crate::page::Page;
-        let dir = std::env::temp_dir().join("cce-designer-page-tests");
+        let dir = std::env::temp_dir()
+            .join(format!("cce-designer-page-tests-{}", std::process::id()));
         std::fs::create_dir_all(&dir).unwrap();
         let path = dir.join("sheet.png");
         let p = Page::new([8.5, 11.0], 300, [1.0, 1.0, 1.0, 1.0]);