From 5a5fd9978dcbe1ba7cbe949f8b248da39319f50e Mon Sep 17 00:00:00 2001 From: faumaray Date: Wed, 28 Oct 2026 08:03:17 +0300 Subject: [PATCH] voelin-gpui: the banner test removes the sample pictures' folder it made a_banner_is_drawn_under_a_veil opens the sample servers with their pictures, which are files of a folder named voelin-gpui-demo--N in the temporary directory; the window's close removes it (AppState::shutdown), but the test never closes the window and the entity of a gpui test is not released when the test ends, so every run of the lib binary left a folder: eight runs with TMPDIR pointing at an empty directory left eight. The test ends with the app's shutdown now, after asserting that the folder was there and is gone; eight runs leave TMPDIR empty. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-gpui/src/app.rs | 6 ++++++ crates/voelin-gpui/src/view.rs | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/crates/voelin-gpui/src/app.rs b/crates/voelin-gpui/src/app.rs index 7888206..415c690 100644 --- a/crates/voelin-gpui/src/app.rs +++ b/crates/voelin-gpui/src/app.rs @@ -566,6 +566,12 @@ impl AppState { std::mem::take(&mut *self.sent.borrow_mut()) } + /// The folder the sample pictures were written to, while there is one. + #[cfg(test)] + pub(crate) fn demo_dir(&self) -> Option<&PathBuf> { + self.demo_dir.as_ref() + } + /// A command for the session on screen. fn command(&self, f: impl FnOnce(u64) -> Command) { if let Some(id) = self.vm.current { diff --git a/crates/voelin-gpui/src/view.rs b/crates/voelin-gpui/src/view.rs index efd1888..748fb09 100644 --- a/crates/voelin-gpui/src/view.rs +++ b/crates/voelin-gpui/src/view.rs @@ -1289,6 +1289,14 @@ mod tests { assert!(!tinted(cx, second)); click(cx, &format!("tree-channel-{second}")); assert!(tinted(cx, second) && !tinted(cx, first), "and the tint follows the selection"); + + // The sample pictures are files of a folder of the state's own in the + // temporary directory; the window's close, as the app ends, removes it + // (the entity of a test is not released when the test ends). + let folder = shell.app.read_with(cx, |app, _| app.demo_dir().cloned()); + assert!(folder.as_ref().is_some_and(|folder| folder.is_dir()), "{folder:?}"); + shell.app.update(cx, |app, cx| app.shutdown(cx)); + assert!(!folder.is_some_and(|folder| folder.exists()), "the close removes it"); } /// A person who changes channel makes the rows between the two places