From 8ad3ee0e9d122aba6d2cb14798604c7512cb5ea2 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Wed, 12 Nov 2025 10:18:45 +0100 Subject: [PATCH] Fix flaky PartRenderingEngineTests.ensureCleanUpAddonCleansUp race condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test was failing intermittently with "CleanupAddon should ensure that partStack is not rendered anymore, as all childs have been removed" because it was checking the cleanup result before the async cleanup logic had a chance to execute. Root cause: - CleanupAddon performs cleanup asynchronously via Display.asyncExec() (CleanupAddon.java:352) - When hidePart() is called, it triggers events that schedule async cleanup tasks on the event queue - The test was calling waitForCondition() immediately after hiding parts, before the async cleanup tasks were even posted to the event queue - This created a race where the wait could timeout before cleanup started Fix: - Add contextRule.spinEventLoop() after hiding partB and partC to ensure async cleanup tasks are processed before waiting for the condition - Wrap waitForCondition() in assertTrue() to fail immediately with a clear message if cleanup doesn't complete within timeout - Remove redundant assertFalse() statements This matches the pattern used in the adjacent testBug332463 test which calls spinEventLoop() after each hidePart() call. Verified with 5 consecutive test runs - all passed (consistently completing in ~0.028-0.036s). Fixes https://github.com/eclipse-platform/eclipse.platform.ui/issues/751 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../e4/ui/tests/workbench/PartRenderingEngineTests.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java b/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java index d597622a8ee..1d794e927e3 100644 --- a/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java +++ b/tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java @@ -2466,12 +2466,11 @@ public void ensureCleanUpAddonCleansUp() { assertTrue(" PartStack with children should be rendered", partStackForPartBPartC.isToBeRendered()); partService.hidePart(partB); partService.hidePart(partC); - DisplayHelper.waitForCondition(Display.getDefault(), 5_000, - () -> partStackForPartBPartC.isToBeRendered() == false); - assertFalse( + contextRule.spinEventLoop(); + assertTrue( "CleanupAddon should ensure that partStack is not rendered anymore, as all childs have been removed", - partStackForPartBPartC.isToBeRendered()); - assertFalse("Part stack should be removed", partStackForPartBPartC.isToBeRendered()); + DisplayHelper.waitForCondition(Display.getDefault(), 5_000, + () -> partStackForPartBPartC.isToBeRendered() == false)); // PartStack with IPresentationEngine.NO_AUTO_COLLAPSE should not be removed // even if children are removed partService.hidePart(editor, true);