Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added test for Re #1000607

(cherry picked from commit 9b8ed82)

Conflicts:

	org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/sbtbuilder/ScalaJavaDepTest.scala
  • Loading branch information...
commit 02336198a3cc32f70699847b4c4f48210a432115 1 parent a903ca6
Luc Bourlier skyluc authored
82 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/sbtbuilder/ScalaJavaDepTest.scala
View
@@ -8,7 +8,7 @@ import org.eclipse.core.resources.IncrementalProjectBuilder
import org.eclipse.jdt.core.IJavaModelMarker
import org.eclipse.core.resources.IResource
-import org.junit.Assert
+import org.junit.Assert._
import org.eclipse.core.resources.IMarker
import scala.tools.eclipse.testsetup.SDTTestUtils
@@ -29,61 +29,86 @@ class ScalaJavaDepTest {
@Test def testSimpleScalaDep() {
println("building " + project)
- project.clean(new NullProgressMonitor())
- rebuild(project, false)
+ cleanProject
+
+ def getProblemMarkers= getProblemMarkersFor("test/J.java", "test/S.scala")
val problems0 = getProblemMarkers
- Assert.assertTrue("Build errors found: " + userFriendlyMarkers(problems0), problems0.isEmpty)
+ assertTrue("Build errors found: " + userFriendlyMarkers(problems0), problems0.isEmpty)
val JJavaCU = compilationUnit("test/J.java")
val originalJJava = SDTTestUtils.slurpAndClose(project.underlying.getFile("src/test/J.java").getContents)
SDTTestUtils.changeContentOfFile(project.underlying, JJavaCU.getResource().getAdapter(classOf[IFile]).asInstanceOf[IFile], changedJJava)
rebuild(project)
- val problems1 = getProblemMarkers()
- Assert.assertTrue("One build error expected, got: " + userFriendlyMarkers(problems1), problems1.length == 1) // do more precise matching later
+ val problems1 = getProblemMarkers
+ assertTrue("One build error expected, got: " + userFriendlyMarkers(problems1), problems1.length == 1) // do more precise matching later
val JJavaCU2 = compilationUnit("test/J.java")
SDTTestUtils.changeContentOfFile(project.underlying, JJavaCU2.getResource().getAdapter(classOf[IFile]).asInstanceOf[IFile], originalJJava)
rebuild(project)
- val problems2 = getProblemMarkers()
- Assert.assertTrue("Build errors found: " + userFriendlyMarkers(problems2), problems2.isEmpty)
+ val problems2 = getProblemMarkers
+ assertTrue("Build errors found: " + userFriendlyMarkers(problems2), problems2.isEmpty)
}
@Ignore
@Test def testSimpleJavaDep() {
println("building " + project)
- project.clean(new NullProgressMonitor())
- rebuild(project, false)
+ cleanProject
+
+ def getProblemMarkers= getProblemMarkersFor("test/J.java", "test/S.scala")
- val problems0 = getProblemMarkers()
- Assert.assertTrue("Build errors found: " + userFriendlyMarkers(problems0), problems0.isEmpty)
+ val problems0 = getProblemMarkers
+ assertTrue("Build errors found: " + userFriendlyMarkers(problems0), problems0.isEmpty)
val SScalaCU = compilationUnit("test/S.scala")
val originalSScala = SDTTestUtils.slurpAndClose(project.underlying.getFile("src/test/S.scala").getContents)
SDTTestUtils.changeContentOfFile(project.underlying, SScalaCU.getResource().getAdapter(classOf[IFile]).asInstanceOf[IFile], changedSScala)
rebuild(project)
- val problems1 = getProblemMarkers()
- Assert.assertTrue("One build error expected: " + userFriendlyMarkers(problems1), problems1.length == 1) // do more precise matching later
+ val problems1 = getProblemMarkers
+ assertTrue("One build error expected: " + userFriendlyMarkers(problems1), problems1.length == 1) // do more precise matching later
val SScalaCU2 = compilationUnit("test/S.scala")
SDTTestUtils.changeContentOfFile(project.underlying, SScalaCU2.getResource().getAdapter(classOf[IFile]).asInstanceOf[IFile], originalSScala)
rebuild(project)
- val problems2 = getProblemMarkers()
- Assert.assertTrue("Build errors found: " + userFriendlyMarkers(problems2), problems2.isEmpty)
- }
+ val problems2 = getProblemMarkers
+ assertTrue("Build errors found: " + userFriendlyMarkers(problems2), problems2.isEmpty)
+ }
- def rebuild(prj: ScalaProject, incremental: Boolean = true): List[IMarker] = {
+ def rebuild(prj: ScalaProject) {
println("building " + prj)
- val buildType = if (incremental) IncrementalProjectBuilder.INCREMENTAL_BUILD else IncrementalProjectBuilder.FULL_BUILD
- prj.underlying.build(buildType, new NullProgressMonitor)
- getProblemMarkers()
+ prj.underlying.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor)
}
- def getProblemMarkers(): List[IMarker] = {
- val units = compilationUnits("test/J.java", "test/S.scala").toList
+ @Test def ticket_1000607() {
+ def getProblemMarkers= getProblemMarkersFor("ticket_1000607/A.scala", "ticket_1000607/C.java")
+
+ // do a clean build and check the expected error
+ cleanProject
+ var problems= getProblemMarkers
+ assertEquals("One error expected: " + userFriendlyMarkers(problems), 1, problems.size)
+
+ // "fix" the scala code
+ val aClass= compilationUnit("ticket_1000607/A.scala")
+ SDTTestUtils.changeContentOfFile(project.underlying, aClass.getResource().asInstanceOf[IFile], changed_ticket_1000607_A)
+
+ // trigger incremental compile
+ project.underlying.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor)
+
+ // and check that the error disappeared
+ problems= getProblemMarkers
+ assertTrue("Unexpected error: " + userFriendlyMarkers(problems), problems.isEmpty)
+ }
+
+ def getProblemMarkersFor(paths: String*): List[IMarker] = {
+ val units = compilationUnits(paths: _*).toList
units.flatMap(SDTTestUtils.findProblemMarkers)
}
+ private def cleanProject: Unit = {
+ project.underlying.build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor)
+ project.underlying.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor)
+ }
+
def userFriendlyMarkers(markers: List[IMarker]) = markers.map(_.getAttribute(IMarker.MESSAGE))
lazy val changedJJava = """
@@ -106,4 +131,15 @@ class S {
def foo1(s:String) { println(new J().bar(s)) }
}
"""
+
+ lazy val changed_ticket_1000607_A = """
+package ticket_1000607
+
+trait A {
+ def foo(s: String): Unit = {}
+}
+
+abstract class B extends A
+"""
+
}
7 org.scala-ide.sdt.core.tests/test-workspace/scalajavadep/src/ticket_1000607/A.scala
View
@@ -0,0 +1,7 @@
+package ticket_1000607
+
+trait A {
+ def foo(s: String): Unit //= {}
+}
+
+abstract class B extends A
5 org.scala-ide.sdt.core.tests/test-workspace/scalajavadep/src/ticket_1000607/C.java
View
@@ -0,0 +1,5 @@
+package ticket_1000607;
+
+public class C extends B {
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.