Skip to content

Commit

Permalink
Merge pull request sbt#1390 from eed3si9n/wip/stricter_test
Browse files Browse the repository at this point in the history
[2.x] Make unit test stricter
  • Loading branch information
eed3si9n authored Sep 6, 2024
2 parents fada025 + 9a5a9b4 commit 6a75537
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion zinc/src/test/scala/sbt/inc/TestProjectSetup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
package sbt
package inc

import java.io.FileNotFoundException
import java.net.URLClassLoader
import java.nio.file.{ Files, Path, Paths }
import java.util.Optional
Expand Down Expand Up @@ -136,7 +137,14 @@ case class CompilerSetup(
store: AnalysisStore,
newInputs: Inputs => Inputs,
): CompileResult = {
val prevRes = store.get().toOption.fold(zinc.emptyPreviousResult)(zinc.previousResult(_))
// only allow FileNotFoundException to silently use empty previous result
val prevRes =
try {
zinc.previousResult(store.unsafeGet())
} catch {
case _: FileNotFoundException => zinc.emptyPreviousResult
case _: NoSuchElementException => zinc.emptyPreviousResult
}
val newResult = doCompile(inputs => newInputs(inputs.withPreviousResult(prevRes)))
store.set(AnalysisContents.create(newResult.analysis, newResult.setup))
newResult
Expand Down

0 comments on commit 6a75537

Please sign in to comment.