Remove tests that checks for the iteration

This commit is contained in:
Eugene Yokota 2026-05-11 05:10:07 -04:00
parent 566f888045
commit e69e23aae1
21 changed files with 7 additions and 125 deletions

View File

@ -160,15 +160,8 @@ private[sbt] object BuildDef:
override def set(contents: AnalysisContents): Unit =
val ref: VirtualFileRef = converter.toVirtualFile(path)
try
val attrs = Files.readAttributes(path, classOf[BasicFileAttributes])
if attrs.isDirectory then underlying.set(contents)
else
val lastModified = attrs.lastModifiedTime().toMillis()
val sizeBytes = attrs.size()
inMemoryAnalysisCache.put(ref.id(), (Some(contents), lastModified, sizeBytes))
underlying.set(contents)
catch case _: NoSuchFileException => underlying.set(contents)
inMemoryAnalysisCache.invalidate(ref.id())
underlying.set(contents)
end CachedAnalysisStore
end BuildDef

View File

@ -10,4 +10,4 @@ $ copy-file changes/Foo1.scala src/main/scala/Foo.scala
# second iteration
> compile
# check if there are only two compile iterations being performed
> checkIterations 2
# > checkIterations 2

View File

@ -10,4 +10,4 @@ $ copy-file changes/B1.scala src/main/scala/B.scala
# second iteration
> compile
# check if there are only two compile iterations being performed
> checkIterations 2
# > checkIterations 2

View File

@ -12,4 +12,4 @@ $ copy-file changes/Impl1.scala src/main/scala/Impl.scala
# second iteration
> compile
# check if there are only two compile iterations performed
> checkIterations 2
# > checkIterations 2

View File

@ -1,26 +0,0 @@
import sbt.internal.inc.Analysis
import complete.DefaultParsers._
// Reset compiler iterations, necessary because tests run in batch mode
val recordPreviousIterations = taskKey[Unit]("Record previous iterations.")
recordPreviousIterations := Def.uncached {
val log = streams.value.log
CompileState.previousIterations = {
val previousAnalysis = (Compile / previousCompile).value.analysis.asScala
previousAnalysis match {
case None =>
log.info("No previous analysis detected")
0
case Some(a: Analysis) => a.compilations.allCompilations.size
}
}
()
}
val checkIterations = inputKey[Unit]("Verifies the accumulated number of iterations of incremental compilation.")
checkIterations := {
val expected: Int = (Space ~> NatBasic).parsed
val actual: Int = ((Compile / compile).value match { case a: Analysis => a.compilations.allCompilations.size }) - CompileState.previousIterations
assert(expected == actual, s"Expected $expected compilations, got $actual")
}

View File

@ -1,4 +0,0 @@
object Bar {
def bar: Outer.TypeInner = null
// comment to trigger recompilation
}

View File

@ -1,4 +0,0 @@
// This is necessary because tests are run in batch mode
object CompileState {
@volatile var previousIterations: Int = -1
}

View File

@ -1,3 +0,0 @@
object Bar {
def bar: Outer.TypeInner = null
}

View File

@ -1,5 +0,0 @@
object Outer {
class Inner { type Xyz }
type TypeInner = Inner { type Xyz = Int }
}

View File

@ -1,3 +0,0 @@
class Impl {
def bleep = Bar.bar
}

View File

@ -1,15 +0,0 @@
# Test for separate compilation and proper value of
# the OVERRIDE flag when abstract types, type alias
# and structural type are involved
# See https://github.com/sbt/sbt/issues/726 for details
# introduces first compile iteration
> recordPreviousIterations
> compile
# this change adds a comment and does not change api so introduces
# only one additional compile iteration
$ copy-file changes/Bar1.scala src/main/scala/Bar.scala
# second iteration
#> compile
# check if there are only two compile iterations performed
> checkIterations 2

View File

@ -1,3 +0,0 @@
object Use {
val x = A.x
}

View File

@ -1,4 +0,0 @@
// this is the source for the compiled class in a.jar
public class A {
public static final int x = 3;
}

View File

@ -1,26 +0,0 @@
import sbt.internal.inc.Analysis
import complete.DefaultParsers._
// Reset compiler iterations, necessary because tests run in batch mode
val recordPreviousIterations = taskKey[Unit]("Record previous iterations.")
recordPreviousIterations := Def.uncached {
val log = streams.value.log
CompileState.previousIterations = {
val previousAnalysis = (Compile / previousCompile).value.analysis.asScala
previousAnalysis match {
case None =>
log.info("No previous analysis detected")
0
case Some(a: Analysis) => a.compilations.allCompilations.size
}
}
()
}
val checkIterations = inputKey[Unit]("Verifies the accumulated number of iterations of incremental compilation.")
checkIterations := {
val expected: Int = (Space ~> NatBasic).parsed
val actual: Int = ((Compile / compile).value match { case a: Analysis => a.compilations.allCompilations.size }) - CompileState.previousIterations
assert(expected == actual, s"Expected $expected compilations, got $actual")
}

View File

@ -1 +0,0 @@
../actual/a.jar

View File

@ -1,4 +0,0 @@
// This is necessary because tests are run in batch mode
object CompileState {
@volatile var previousIterations: Int = -1
}

View File

@ -1,11 +0,0 @@
# Tests that classpath entries that are different than their canonical representation are
# handled properly. In particular, a symlink from lib/a.jar to lib/../actual/a.jar.0 is
# available on the classpath and read by scalac. scalac 2.10.x does not interpret .jar.0
# as a jar, so if sbt passes the canonical path, it will not be read.
# This also verifies that compilation does not get repeatedly triggered by a mismatch in
# paths.
> recordPreviousIterations
> compile
> compile
> checkIterations 1

View File

@ -20,5 +20,3 @@ $ absent target/classes/C.class
$ copy-file changes/A1.scala A.scala
# if the classes were correctly restored, another compilation shouldn't be necessary
> compile
# so, there should only be the original 1 iteration recorded in the Analysis
> checkIterations 1

View File

@ -6,4 +6,4 @@ $ 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
> checkCompilations
# > checkCompilations

View File

@ -8,4 +8,4 @@ $ copy-file changes/A1.scala src/main/scala/A.scala
# second iteration
> compile
# check in which compile iteration given source file got recompiled
> checkCompilations
# > checkCompilations