|
9 | 9 | *******************************************************************************/ |
10 | 10 | package org.eclipse.text.quicksearch.tests; |
11 | 11 |
|
12 | | -import static org.junit.jupiter.api.Assertions.assertEquals; |
13 | 12 | import static org.junit.jupiter.api.Assertions.assertTrue; |
14 | 13 |
|
15 | 14 | import java.io.IOException; |
@@ -55,8 +54,16 @@ void testQuickAccessComputer() throws CoreException, IOException { |
55 | 54 | dialog.setInitialPattern(request); |
56 | 55 | dialog.setBlockOnOpen(false); |
57 | 56 | dialog.open(); |
58 | | - assertTrue(DisplayHelper.waitForCondition(dialog.getShell().getDisplay(), 2000, () -> dialog.getResult().length > 0)); |
| 57 | + var display = dialog.getShell().getDisplay(); |
| 58 | + assertTrue(DisplayHelper.waitForCondition(display, 2000, () -> dialog.getResult().length > 0)); |
59 | 59 | dialog.close(); |
60 | | - assertEquals(1, new QuickSearchQuickAccessComputer().computeElements(request, new NullProgressMonitor()).length); |
| 60 | + |
| 61 | + // Wait for the QuickAccessComputer to return results, as the search happens asynchronously. |
| 62 | + // Retry the search if it initially returns no results, allowing time for the background |
| 63 | + // search job to find matches. This addresses race conditions on slower CI systems. |
| 64 | + assertTrue(DisplayHelper.waitForCondition(display, 5000, () -> { |
| 65 | + QuickSearchQuickAccessComputer computer = new QuickSearchQuickAccessComputer(); |
| 66 | + return computer.computeElements(request, new NullProgressMonitor()).length == 1; |
| 67 | + }), "Expected QuickAccessComputer to find exactly one result within timeout"); |
61 | 68 | } |
62 | 69 | } |
0 commit comments