Skip to content

Commit

Permalink
DiagnosticHandlerTest.testMultipleLineRange fails randomly
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <[email protected]>
  • Loading branch information
snjeza authored and fbricon committed Dec 6, 2018
1 parent 9328272 commit f49767b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ public void testUnneededCatchBlockWithFinally() throws Exception {
public void testRemoveUnreachableCodeStmt() throws Exception {
Hashtable<String, String> hashtable = JavaCore.getOptions();
hashtable.put(JavaCore.COMPILER_PB_UNNECESSARY_ELSE, JavaCore.IGNORE);
JavaCore.setOptions(hashtable);
fJProject1.setOptions(hashtable);

IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
StringBuilder buf = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.junit.Assert.assertNotEquals;

import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;

import org.eclipse.core.resources.IFile;
Expand All @@ -24,6 +25,7 @@
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IProblemRequestor;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.WorkingCopyOwner;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.CompilationUnit;
Expand Down Expand Up @@ -51,6 +53,9 @@ public void setup() throws Exception {
@Test
public void testMultipleLineRange() throws Exception {
IJavaProject javaProject = newEmptyProject();
Hashtable<String, String> options = JavaCore.getOptions();
options.put(JavaCore.COMPILER_PB_DEAD_CODE, JavaCore.WARNING);
javaProject.setOptions(options);
IPackageFragmentRoot sourceFolder = javaProject.getPackageFragmentRoot(javaProject.getProject().getFolder("src"));
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);

Expand All @@ -69,7 +74,7 @@ public void testMultipleLineRange() throws Exception {
CompilationUnit astRoot = CoreASTProvider.getInstance().getAST(cu, CoreASTProvider.WAIT_YES, monitor);
IProblem[] problems = astRoot.getProblems();
List<Diagnostic> diagnostics = DiagnosticsHandler.toDiagnosticsArray(cu, Arrays.asList(problems));
assertEquals(diagnostics.size(), 1);
assertEquals(1, diagnostics.size());
Range range = diagnostics.get(0).getRange();
assertNotEquals(range.getStart().getLine(), range.getEnd().getLine());
}
Expand Down

0 comments on commit f49767b

Please sign in to comment.