diff options
Diffstat (limited to 'bridge/src/sbt-test/compilerReporter/simple')
5 files changed, 74 insertions, 0 deletions
diff --git a/bridge/src/sbt-test/compilerReporter/simple/Source.scala b/bridge/src/sbt-test/compilerReporter/simple/Source.scala new file mode 100644 index 000000000..6f0678599 --- /dev/null +++ b/bridge/src/sbt-test/compilerReporter/simple/Source.scala @@ -0,0 +1,10 @@ +trait A +trait B + +trait Wr { + val z: A with B +} + +object Er { + val a = er1 +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/compilerReporter/simple/build.sbt b/bridge/src/sbt-test/compilerReporter/simple/build.sbt new file mode 100644 index 000000000..017846f5e --- /dev/null +++ b/bridge/src/sbt-test/compilerReporter/simple/build.sbt @@ -0,0 +1 @@ +Reporter.checkSettings
\ No newline at end of file diff --git a/bridge/src/sbt-test/compilerReporter/simple/project/DottyInjectedPlugin.scala b/bridge/src/sbt-test/compilerReporter/simple/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000..3433779b6 --- /dev/null +++ b/bridge/src/sbt-test/compilerReporter/simple/project/DottyInjectedPlugin.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := "0.1-SNAPSHOT", + scalaOrganization := "ch.epfl.lamp", + scalacOptions += "-language:Scala2", + scalaBinaryVersion := "2.11", + autoScalaLibrary := false, + libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), + scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() + ) +} diff --git a/bridge/src/sbt-test/compilerReporter/simple/project/Reporter.scala b/bridge/src/sbt-test/compilerReporter/simple/project/Reporter.scala new file mode 100644 index 000000000..1c5952d28 --- /dev/null +++ b/bridge/src/sbt-test/compilerReporter/simple/project/Reporter.scala @@ -0,0 +1,45 @@ +import sbt._ +import Keys._ +import KeyRanks.DTask + +object Reporter { + import xsbti.{Reporter, Problem, Position, Severity, Maybe} + + lazy val check = TaskKey[Unit]("check", "make sure compilation info are forwared to sbt") + + // compilerReporter is marked private in sbt + lazy val compilerReporter = TaskKey[Option[xsbti.Reporter]]("compilerReporter", "Experimental hook to listen (or send) compilation failure messages.", DTask) + + lazy val reporter = + Some(new xsbti.Reporter { + private val buffer = collection.mutable.ArrayBuffer.empty[Problem] + def reset(): Unit = buffer.clear() + def hasErrors: Boolean = buffer.exists(_.severity == Severity.Error) + def hasWarnings: Boolean = buffer.exists(_.severity == Severity.Warn) + def printSummary(): Unit = println(problems.mkString(System.lineSeparator)) + def problems: Array[Problem] = buffer.toArray + def log(pos: Position, msg: String, sev: Severity): Unit = { + object MyProblem extends Problem { + def category: String = null + def severity: Severity = sev + def message: String = msg + def position: Position = pos + override def toString = s"custom: $position:$severity: $message" + } + buffer.append(MyProblem) + } + def comment(pos: xsbti.Position, msg: String): Unit = () + }) + + lazy val checkSettings = Seq( + compilerReporter in (Compile, compile) := reporter, + check <<= (compile in Compile).mapFailure( _ => { + val problems = reporter.get.problems + println(problems.toList) + assert(problems.size == 3) + assert(problems.count(_.severity == Severity.Error) == 1) // not found: er1, + assert(problems.count(_.severity == Severity.Warn) == 1) // `with' as a type operator has been deprecated; use `&' instead, + assert(problems.count(_.severity == Severity.Info) == 1) // one error found + }) + ) +}
\ No newline at end of file diff --git a/bridge/src/sbt-test/compilerReporter/simple/test b/bridge/src/sbt-test/compilerReporter/simple/test new file mode 100644 index 000000000..a5912a391 --- /dev/null +++ b/bridge/src/sbt-test/compilerReporter/simple/test @@ -0,0 +1 @@ +> check
\ No newline at end of file |