mirror of https://github.com/sbt/sbt.git
Test diagnostics from Java
This commit is contained in:
parent
799adcda2b
commit
ecc4469c3e
|
|
@ -36,6 +36,12 @@ lazy val util = project.settings(
|
||||||
|
|
||||||
lazy val diagnostics = project
|
lazy val diagnostics = project
|
||||||
|
|
||||||
|
lazy val javaProj = project
|
||||||
|
.in(file("java-proj"))
|
||||||
|
.settings(
|
||||||
|
javacOptions += "-Xlint:all"
|
||||||
|
)
|
||||||
|
|
||||||
def somethingBad = throw new MessageOnlyException("I am a bad build target")
|
def somethingBad = throw new MessageOnlyException("I am a bad build target")
|
||||||
// other build targets should not be affected by this bad build target
|
// other build targets should not be affected by this bad build target
|
||||||
lazy val badBuildTarget = project.in(file("bad-build-target"))
|
lazy val badBuildTarget = project.in(file("bad-build-target"))
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package example;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
class Hello {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
List list = new ArrayList<String>();
|
||||||
|
String msg = 42;
|
||||||
|
System.out.println(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -245,6 +245,32 @@ object BuildServerTest extends AbstractServerTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("buildTarget/compile: Java diagnostics") { _ =>
|
||||||
|
val buildTarget = buildTargetUri("javaProj", "Compile")
|
||||||
|
|
||||||
|
compile(buildTarget)
|
||||||
|
|
||||||
|
assert(
|
||||||
|
svr.waitForString(10.seconds) { s =>
|
||||||
|
s.contains("build/publishDiagnostics") &&
|
||||||
|
s.contains("Hello.java") &&
|
||||||
|
s.contains(""""severity":2""") &&
|
||||||
|
s.contains("""missing type arguments for generic class java.util.List""")
|
||||||
|
},
|
||||||
|
"should send publishDiagnostics with serverity 2 for Hello.java"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert(
|
||||||
|
svr.waitForString(1.seconds) { s =>
|
||||||
|
s.contains("build/publishDiagnostics") &&
|
||||||
|
s.contains("Hello.java") &&
|
||||||
|
s.contains(""""severity":1""") &&
|
||||||
|
s.contains("""incompatible types: int cannot be converted to java.lang.String""")
|
||||||
|
},
|
||||||
|
"should send publishDiagnostics with serverity 1 for Hello.java"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
test("buildTarget/scalacOptions") { _ =>
|
test("buildTarget/scalacOptions") { _ =>
|
||||||
val buildTarget = buildTargetUri("util", "Compile")
|
val buildTarget = buildTargetUri("util", "Compile")
|
||||||
val badBuildTarget = buildTargetUri("badBuildTarget", "Compile")
|
val badBuildTarget = buildTargetUri("badBuildTarget", "Compile")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue