Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
Expand Down Expand Up @@ -601,12 +603,31 @@ private void testBinaryContentTypeWithDescriber(TestResultCollector collector) t
.forEach(extension -> registry.removeExtension(extension, masterToken));
}) {

// Wait for content type to be registered and available
// This prevents race conditions where the content type might not be immediately available
IContentTypeManager contentTypeManager= Platform.getContentTypeManager();
IContentType binaryContentType= null;
for (int i= 0; i < 50 && binaryContentType == null; i++) {
binaryContentType= contentTypeManager.getContentType("org.eclipse.search.tests.binaryFile");
if (binaryContentType == null) {
Thread.sleep(10); // Wait 10ms before retrying
}
}
if (binaryContentType == null) {
throw new AssertionError("Content type 'org.eclipse.search.tests.binaryFile' was not registered");
}

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

// Force content type detection on files to ensure the newly registered content type is applied
// This helps avoid race conditions where the content type might not be immediately available
textfile.getContentDescription();
binaryfile.getContentDescription();

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

// Search only in the unique folder to avoid interference from other tests
Expand Down
Loading