Add a pending test for sbt/sbt#1142

Add a scripted test documents the current behavior of incremental
compiler when it comes to handling of inherited macros. A whitespace
change to a file that inherits a macro triggers recompilation of all files that
depend (by composition or inheritance) on that file.
This commit is contained in:
Martin Duhem 2014-03-16 16:35:39 +01:00
parent 7f8d4ba8bf
commit b5b07348f0
7 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,7 @@
package macro
object Client {
object RealClient extends Provider {
// Some comment...
}
}

View File

@ -0,0 +1,9 @@
// Check that a file has not been recompiled during last compilation
InputKey[Unit]("check-not-recompiled") <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
(argTask, compile in Compile) map { (args: Seq[String], a: sbt.inc.Analysis) =>
assert(args.size == 1)
val fileCompilation = a.apis.internal.collect { case (file, src) if file.name.endsWith(args(0)) => src.compilation }.head
val lastCompilation = a.compilations.allCompilations.last
assert(fileCompilation.startTime != lastCompilation.startTime, "File has been recompiled during last compilation.")
}
}

View File

@ -0,0 +1,7 @@
package macro
object Client {
object RealClient extends Provider {
}
}

View File

@ -0,0 +1,5 @@
package macro
object Foo {
val c = Client.RealClient
}

View File

@ -0,0 +1,7 @@
package macro
import scala.language.experimental.macros
import scala.reflect.macros._
abstract class Provider {
def notImplementedMacro = macro ???
}

View File

@ -0,0 +1,12 @@
> macro-provider/compile
> macro-client/compile
# Introduce a comment in Client, which inherits a macro from Provider
$ copy-file changes/Client.scala macro-client/src/main/scala/Client.scala
> macro-client/compile
# Object Foo depends on Client via composition, thus a whitespace change to
# Client shouldn't trigger its recompilation
> check-not-recompiled Foo.scala

View File

@ -0,0 +1,29 @@
import sbt._
import Keys._
object build extends Build {
val defaultSettings = Seq(
libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-reflect" % _ )//,
//incOptions := incOptions.value.withNameHashing(true)
)
lazy val root = Project(
base = file("."),
id = "macro",
aggregate = Seq(macroProvider, macroClient),
settings = Defaults.defaultSettings ++ defaultSettings
)
lazy val macroProvider = Project(
base = file("macro-provider"),
id = "macro-provider",
settings = Defaults.defaultSettings ++ defaultSettings
)
lazy val macroClient = Project(
base = file("macro-client"),
id = "macro-client",
dependencies = Seq(macroProvider),
settings = Defaults.defaultSettings ++ defaultSettings
)
}