[2.x] test: Add move-file test (#9197)

**Problem**
Moving files around seems to break compile task.
This commit is contained in:
eugene yokota 2026-05-07 11:23:22 -04:00 committed by GitHub
parent 1f151ad6e3
commit 59c007d6a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,5 @@
package example
object Main {
def main(args: Array[String]): Unit = ()
}

View File

@ -0,0 +1,15 @@
import sbt.internal.inc.Analysis
import complete.DefaultParsers.*
scalaVersion := "2.13.18"
val checkStampSize = inputKey[Unit]("Verifies the accumulated number of iterations of incremental compilation.")
checkStampSize := {
val expected: Int = (Space ~> NatBasic).parsed
val analysis = (Compile / compile).value match
case a: Analysis => a
println(s"analysis: $analysis")
val sourceStampSize = analysis.readStamps.getAllSourceStamps.size
assert(sourceStampSize == expected, s"sourceStampSize = $sourceStampSize")
}

View File

@ -0,0 +1,17 @@
> checkStampSize 1
# move A.scala elsewhere
$ copy-file A.scala A.txt
$ delete A.scala
> checkStampSize 0
# move A.scala back
$ copy-file A.txt A.scala
$ delete A.txt
$ exists A.scala
> show Compile/sources
# if we recompile, we should regain stamp size 1
> debug
> checkStampSize 1