mirror of https://github.com/sbt/sbt.git
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:
parent
d198ea4099
commit
0cbbe8c2ed
|
|
@ -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"))
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package test3
|
||||||
|
|
||||||
|
trait A
|
||||||
|
|
@ -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
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package test3
|
||||||
|
|
||||||
|
trait A {
|
||||||
|
def foo = 1
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package test3
|
||||||
|
|
||||||
|
trait B extends A
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package test3
|
||||||
|
|
||||||
|
trait C {
|
||||||
|
def abc(a: A): Int = a.foo
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue