You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix race condition in NestedResourcesTests.testProjectHierarchy
This commit fixes the intermittent test failure reported in GitHub issue #196
where testProjectHierarchy randomly fails with "expected:<2> but was:<1>" at
line 96 (now line 111).
Root cause:
The NestedProjectManager uses an asynchronous IResourceChangeListener that
responds to POST_CHANGE events to update its internal project hierarchy map
(locationsToProjects). When projects are created and opened in rapid
succession, the test may query getDirectChildrenProjects() before the manager
has finished processing all resource change events, leading to incomplete
results.
The specific failure occurred at the assertion checking that projectAB has 2
children (projectABA and projectABB). The test would sometimes only see 1
child because the second project's creation event hadn't been processed yet.
Solution:
Added DisplayHelper.waitForCondition() calls at three critical synchronization
points to wait for NestedProjectManager to process all resource changes before
making assertions:
1. Wait for projectA to show 1 child (projectAB)
2. Wait for folderAA to show 1 child (projectAAA)
3. Wait for projectAB to show 2 children (projectABA and projectABB)
This approach follows the same pattern already used successfully in the
testProblemDecoration() method in the same test file (lines 161-188), which
also waits for asynchronous marker updates to propagate.
The 2-second timeout (TIMEOUT constant) provides sufficient time for event
processing while still failing quickly if assertions are genuinely incorrect.
Fixes: #196
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Copy file name to clipboardExpand all lines: tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/resources/NestedResourcesTests.java
+15Lines changed: 15 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -81,17 +81,32 @@ public void testProjectHierarchy() throws Exception {
81
81
testProjects.add(projectABA);
82
82
testProjects.add(projectABB);
83
83
84
+
// Wait for NestedProjectManager to process all resource changes
85
+
assertTrue("NestedProjectManager did not update children for projectA",
0 commit comments