Skip to content

Commit

Permalink
Add unit test for #1234
Browse files Browse the repository at this point in the history
  • Loading branch information
Friendseeker committed Dec 30, 2023
1 parent 0034a23 commit b20c83c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions zinc/src/test/scala/sbt/inc/BaseCompilerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class BaseCompilerSpec extends BridgeProviderSpecification {

def assertExists(p: Path) = assert(Files.exists(p), s"$p does not exist")

def assertNotExists(p: Path) = assert(Files.notExists(p), s"$p exist")

def lastClasses(a: Analysis) = {
a.compilations.allCompilations.map { c =>
a.apis.internal.collect {
Expand Down
15 changes: 15 additions & 0 deletions zinc/src/test/scala/sbt/inc/IncrementalCompilerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ class IncrementalCompilerSpec extends BaseCompilerSpec {
} finally comp.close()
}

it should "delete all products if extra changes" in withTmpDir { tempDir =>
val comp =
ProjectSetup.simple(tempDir.toPath, Seq(SourceFiles.Good, SourceFiles.Foo)).createCompiler()
val comp2 =
ProjectSetup.simple(tempDir.toPath, Seq(SourceFiles.Foo)).createCompiler()
try {
val cacheFile = tempDir / "target" / "inc_compile.zip"
val fileStore = AnalysisStore.getCachedStore(FileAnalysisStore.binary(cacheFile))
comp.doCompileWithStore(fileStore)
val newSetup = comp2.setup.withExtra(Array())
comp2.doCompileWithStore(fileStore, _.withSetup(newSetup))
assertNotExists(comp.output / "pkg" / "Good$.class")
} finally comp.close()
}

it should "not trigger full compilation for small Scala changes in a mixed project" in withTmpDir {
tmp =>
val project = VirtualSubproject(tmp.toPath / "p1")
Expand Down

0 comments on commit b20c83c

Please sign in to comment.