Skip to content

Commit

Permalink
An attempt to stabilize PositionTrackerTest
Browse files Browse the repository at this point in the history
Acquire workspace lock on the file we are testing to avoid parallel
modifications on it while we are testing.

See eclipse-platform#882
  • Loading branch information
iloveeclipse authored and praveen-skp committed Aug 8, 2023
1 parent 1ae5502 commit 4db3eef
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.junit.ClassRule;
import org.junit.Test;

import org.eclipse.core.runtime.jobs.Job;

import org.eclipse.core.resources.IFile;

import org.eclipse.core.filebuffers.FileBuffers;
Expand Down Expand Up @@ -92,6 +94,7 @@ private void checkInsertInsideMatch(FileSearchResult result, IFile file) throws
try {
SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
ITextFileBuffer fb= FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
Job.getJobManager().beginRule(file, null);
IDocument doc= fb.getDocument();

for (Match matche : matches) {
Expand All @@ -110,6 +113,7 @@ private void checkInsertInsideMatch(FileSearchResult result, IFile file) throws
assertEquals(buf.toString(), ((FileSearchQuery) result.getQuery()).getSearchString());
}
} finally {
Job.getJobManager().endRule(file);
SearchPlugin.getActivePage().closeAllEditors(false);
}
}
Expand All @@ -123,6 +127,7 @@ private void checkInsertAtZero(AbstractTextSearchResult result, IFile file) thro
try {
SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
ITextFileBuffer fb= FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
Job.getJobManager().beginRule(file, null);
IDocument doc= fb.getDocument();
doc.replace(0, 0, "Test");

Expand All @@ -133,6 +138,7 @@ private void checkInsertAtZero(AbstractTextSearchResult result, IFile file) thro

}
} finally {
Job.getJobManager().endRule(file);
SearchPlugin.getActivePage().closeAllEditors(false);
}
}
Expand Down

0 comments on commit 4db3eef

Please sign in to comment.