Add pending scripted test for Ant-style compilation.

Add pending test for Ant-style incremental compilation. In that mode
incremental compiler will recompile only the source files that were changed
by the user and won't try to invalidate any dependencies.

Once Ant-style incremental compilation is implemented this test should be
passing.
This commit is contained in:
Grzegorz Kossakowski 2014-05-08 19:32:26 +02:00
parent d198ea4099
commit 0cbbe8c2ed
6 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,28 @@
logLevel := Level.Debug
incOptions := incOptions.value.withNameHashing(true)
/* Performs checks related to compilations:
* a) checks in which compilation given set of files was recompiled
* b) checks overall number of compilations performed
*/
TaskKey[Unit]("check-compilations") <<= (compile in Compile, scalaSource in Compile) map { (a: sbt.inc.Analysis, src: java.io.File) =>
def relative(f: java.io.File): java.io.File = f.relativeTo(src) getOrElse f
val allCompilations = a.compilations.allCompilations
val recompiledFiles: Seq[Set[java.io.File]] = allCompilations map { c =>
val recompiledFiles = a.apis.internal.collect {
case (file, api) if api.compilation.startTime == c.startTime => relative(file)
}
recompiledFiles.toSet
}
def recompiledFilesInIteration(iteration: Int, fileNames: Set[String]) = {
val files = fileNames.map(new java.io.File(_))
assert(recompiledFiles(iteration) == files, "%s != %s".format(recompiledFiles(iteration), files))
}
assert(allCompilations.size == 2)
// B.scala and C.scala are compiled at the beginning, in the Ant-style incremental compilation
// they are not rebuild when A.scala.
recompiledFilesInIteration(0, Set("B.scala", "C.scala"))
// A.scala is changed and recompiled
recompiledFilesInIteration(1, Set("A.scala"))
}

View File

@ -0,0 +1,3 @@
package test3
trait A

View File

@ -0,0 +1,9 @@
# introduces first compile iteration
> compile
# this change is local to method and does not change api so introduces
# only one additional compile iteration
$ copy-file changes/A1.scala src/main/scala/A.scala
# second iteration
> compile
# check if there are only two compile iterations performed
> check-compilations

View File

@ -0,0 +1,5 @@
package test3
trait A {
def foo = 1
}

View File

@ -0,0 +1,3 @@
package test3
trait B extends A

View File

@ -0,0 +1,5 @@
package test3
trait C {
def abc(a: A): Int = a.foo
}