diff --git a/sbt/src/sbt-test/compiler-project/inc-ant-style/build.sbt b/sbt/src/sbt-test/compiler-project/inc-ant-style/build.sbt new file mode 100644 index 000000000..b38650b6f --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-ant-style/build.sbt @@ -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")) +} diff --git a/sbt/src/sbt-test/compiler-project/inc-ant-style/changes/A1.scala b/sbt/src/sbt-test/compiler-project/inc-ant-style/changes/A1.scala new file mode 100644 index 000000000..e86bab42e --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-ant-style/changes/A1.scala @@ -0,0 +1,3 @@ +package test3 + +trait A \ No newline at end of file diff --git a/sbt/src/sbt-test/compiler-project/inc-ant-style/pending b/sbt/src/sbt-test/compiler-project/inc-ant-style/pending new file mode 100644 index 000000000..72f5dba3f --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-ant-style/pending @@ -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 diff --git a/sbt/src/sbt-test/compiler-project/inc-ant-style/src/main/scala/A.scala b/sbt/src/sbt-test/compiler-project/inc-ant-style/src/main/scala/A.scala new file mode 100644 index 000000000..4ab580616 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-ant-style/src/main/scala/A.scala @@ -0,0 +1,5 @@ +package test3 + +trait A { + def foo = 1 +} diff --git a/sbt/src/sbt-test/compiler-project/inc-ant-style/src/main/scala/B.scala b/sbt/src/sbt-test/compiler-project/inc-ant-style/src/main/scala/B.scala new file mode 100644 index 000000000..572e3c764 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-ant-style/src/main/scala/B.scala @@ -0,0 +1,3 @@ +package test3 + +trait B extends A diff --git a/sbt/src/sbt-test/compiler-project/inc-ant-style/src/main/scala/C.scala b/sbt/src/sbt-test/compiler-project/inc-ant-style/src/main/scala/C.scala new file mode 100644 index 000000000..c8b935590 --- /dev/null +++ b/sbt/src/sbt-test/compiler-project/inc-ant-style/src/main/scala/C.scala @@ -0,0 +1,5 @@ +package test3 + +trait C { + def abc(a: A): Int = a.foo +}