From 7ba3dbc4b07e72dcc85697e8cb51dcc70b1c8a6f Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 16 Sep 2026 11:59:00 +0200 Subject: [PATCH] Fix a flaky test in `id::debug_format_tests` (#8573) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `with_salt_matches_with` and `with_one_child` built the same `Id` by different routes. The debug source map keeps the first spelling it sees for an `Id` and ignores later ones, so whichever test ran first decided what the other one's `{:?}` printed — and the test order is not fixed. Giving `with_salt_matches_with` sources of its own removes the shared entry. Surfaced by the red `Run tests` on #8571, which does not touch `id.rs`. It reproduces on `main`: running just the two tests together, 10 of 15 runs failed before this change, and 12 runs of the whole module after it failed none. 🤖 This PR was opened by a coding agent (Claude Opus 5). Co-authored-by: Claude Opus 5 (1M context) --- crates/egui/src/id.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/egui/src/id.rs b/crates/egui/src/id.rs index 080327b0..1077f545 100644 --- a/crates/egui/src/id.rs +++ b/crates/egui/src/id.rs @@ -254,10 +254,16 @@ mod debug_format_tests { assert_eq!(format!("{id:?}"), r#"Id::unique(IdSalt::new("foo"))"#); } + // The debug source map memoizes the first spelling it sees for an `Id`, so two tests that + // build the same `Id` by different routes race: whichever runs first decides what the other + // one's `{:?}` prints. Every test here therefore uses sources no other test uses. #[test] fn with_salt_matches_with() { - let parent = Id::unique("parent"); - assert_eq!(parent.with_salt(IdSalt::new("child")), parent.with("child")); + let parent = Id::unique("salted_parent"); + assert_eq!( + parent.with_salt(IdSalt::new("salted_child")), + parent.with("salted_child") + ); } #[test]