Merge pull request #2455 from Duhemm/fport/nameHashing-trait-regression

FPORT: Add a pending test for a modified member of a trait
This commit is contained in:
eugene yokota 2016-02-23 14:26:05 -05:00
commit 6583779bb7
5 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,27 @@
/* 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") := {
val analysis = (compile in Compile).value
val srcDir = (scalaSource in Compile).value
def relative(f: java.io.File): java.io.File = f.relativeTo(srcDir) getOrElse f
val allCompilations = analysis.compilations.allCompilations
val recompiledFiles: Seq[Set[java.io.File]] = allCompilations map { c =>
val recompiledFiles = analysis.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 is just compiled at the beginning
recompiledFilesInIteration(0, Set("B.scala"))
// A.scala is changed and recompiled
recompiledFilesInIteration(1, Set("A.scala"))
}
logLevel := Level.Debug

View File

@ -0,0 +1,3 @@
trait A {
def foo: Int = 12
}

View File

@ -0,0 +1,9 @@
# Test if adding a member to a trait affects classes that refer to that trait
# by a member reference
> compile
# add `foo` method to `A`
$ copy-file changes/A1.scala src/main/scala/A.scala
# only A.scala should be recompiled
> compile
# check if there are only two compile iterations performed
> check-compilations

View File

@ -0,0 +1 @@
class B(a: A)