[2.x] test: Add a regression test for incremental test (#9608)

**Problem/Solution**
This tests incremental test's stability post-version bump.
This commit is contained in:
eugene yokota 2026-08-17 00:07:28 -04:00 committed by GitHub
parent 42f8b949f7
commit c0ffc9dc60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,9 @@
package example
import java.nio.file.{ Files, Paths }
class FooTest extends munit.FunSuite:
test("greeting"):
Files.write(Paths.get("test-ran.marker"), "ran".getBytes)
assertEquals(Foo.greeting, "hello")
end FooTest

View File

@ -0,0 +1,16 @@
Global / localCacheDirectory := baseDirectory.value / "diskcache"
scalaVersion := "3.8.4"
val munit = "org.scalameta" %% "munit" % "1.0.4"
lazy val foo = project
lazy val app = project
.dependsOn(foo)
.settings(
libraryDependencies += munit % Test
)
lazy val root = (project in file("."))
.aggregate(foo, app)

View File

@ -0,0 +1,5 @@
package example
object Foo:
def greeting: String = "hello"
end Foo

View File

@ -0,0 +1,20 @@
# the test suite writes this file as a side effect whenever it actually runs
$ absent test-ran.marker
# warm the disk cache
> app/test
$ exists test-ran.marker
$ delete test-ran.marker
# after a clean, retesting app should fully restore from the disk cache;
# since nothing changed, the test body must not execute again
> clean
> app/test
$ absent test-ran.marker
# bumping foo's version alone (e.g. what sbt-dynver would do on a new commit) must not
# invalidate app's test cache entry, since foo's jar content hasn't changed
> set foo / version := "0.2.0"
> clean
> app/test
$ absent test-ran.marker