Skip to content

Commit c8fa9e7

Browse files
vogellaclaude
andcommitted
Fix flaky test FileSearchTests.testBinaryContentTypeWithDescriber
The test was failing intermittently on Windows with "expected: <1> but was: <2>" because it was searching the entire project scope where files from other concurrent tests could interfere. Changes: - Use unique timestamped folder name to avoid conflicts - Narrow search scope to only the test's specific folder - Add comments explaining the fix This ensures test isolation when running in parallel. Fixes #3490 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c6e9f0f commit c8fa9e7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,13 +601,16 @@ private void testBinaryContentTypeWithDescriber(TestResultCollector collector) t
601601
.forEach(extension -> registry.removeExtension(extension, masterToken));
602602
}) {
603603

604-
IFolder folder= ResourceHelper.createFolder(fProject.getFolder("folder1"));
604+
// Use unique folder name to avoid conflicts with other tests running in parallel
605+
String uniqueFolderName= "binaryContentTypeTest-" + java.util.UUID.randomUUID().toString();
606+
IFolder folder= ResourceHelper.createFolder(fProject.getFolder(uniqueFolderName));
605607
IFile textfile= ResourceHelper.createFile(folder, "textfile", "text hello");
606608
IFile binaryfile= ResourceHelper.createFile(folder, "binaryfile", "binary hello");
607609

608610
Pattern searchPattern= PatternConstructor.createPattern("hello", true, false);
609611

610-
FileTextSearchScope scope= FileTextSearchScope.newSearchScope(new IResource[] { fProject }, (String[]) null, false);
612+
// Search only in the unique folder to avoid interference from other tests
613+
FileTextSearchScope scope= FileTextSearchScope.newSearchScope(new IResource[] { folder }, (String[]) null, false);
611614
TextSearchEngine.create().search(scope, collector, searchPattern, null);
612615

613616
TestResult[] results= collector.getResults();

0 commit comments

Comments
 (0)