Skip to content

Conversation

@vogella
Copy link
Contributor

@vogella vogella commented Oct 22, 2025

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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 22, 2025

Test Results

 3 018 files  ±0   3 018 suites  ±0   2h 35m 51s ⏱️ + 15m 47s
 8 229 tests ±0   7 980 ✅ +1  249 💤 ±0  0 ❌  - 1 
23 607 runs  ±0  22 813 ✅ +1  794 💤 ±0  0 ❌  - 1 

Results for commit 4e1f5df. ± Comparison against base commit bba1bf9.

♻️ This comment has been updated with latest results.

This commit fixes the intermittent test failure reported in GitHub issue eclipse-platform#196 where testProjectHierarchy randomly fails with "expected:<2> but was:<1>" at line 96.

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, 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.

Since the waitForCondition() calls already verify the array lengths, the redundant Assert.assertEquals calls for array lengths have been removed per code review feedback.

Fixes: eclipse-platform#196

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vogella vogella force-pushed the flacky-test-nestled branch from 1f7b2c1 to 4e1f5df Compare October 22, 2025 19:36
@vogella
Copy link
Contributor Author

vogella commented Oct 23, 2025

@fedejeanne is this change now ok for you?

@fedejeanne fedejeanne merged commit 9dee7b7 into eclipse-platform:master Oct 23, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Test] org.eclipse.ui.tests.navigator.resources.NestedResourcesTests.testProjectHierarchy fails on linux intermittently

2 participants