Skip to content

Commit

Permalink
test: fix reindex scala-cli test
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Dec 10, 2024
1 parent 94e4052 commit 007da1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ch.epfl.scala.bsp4j.BuildTargetIdentifier
class FileChanges(buildTargets: BuildTargets, workspace: () => AbsolutePath)(
implicit ec: ExecutionContext
) {
private val previousSignature = TrieMap[AbsolutePath, String]()
private val previousSignatures = TrieMap[AbsolutePath, String]()
private val dirtyBuildTargets = mutable.Set[BuildTargetIdentifier]()

def addAllDirty(
Expand Down Expand Up @@ -121,16 +121,16 @@ class FileChanges(buildTargets: BuildTargets, workspace: () => AbsolutePath)(
fingerprint
.map { fingerprint =>
synchronized {
if (previousSignature.getOrElse(path, null) == fingerprint.md5)
if (previousSignatures.getOrElse(path, null) == fingerprint.md5)
false
else {
previousSignature.put(path, fingerprint.md5)
previousSignatures.put(path, fingerprint.md5)
true
}
}
}
.getOrElse(true)
}

def cancel(): Unit = previousSignature.clear()
def cancel(): Unit = previousSignatures.clear()
}
3 changes: 3 additions & 0 deletions tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import scala.meta.internal.mtags.CoursierComplete

import org.eclipse.{lsp4j => l}
import tests.FileLayout
import scala.concurrent.Promise

// https://github.com/scalameta/metals/issues/6839
class ScalaCliSuite extends BaseScalaCliSuite("3.3.3") {
Expand Down Expand Up @@ -504,9 +505,11 @@ class ScalaCliSuite extends BaseScalaCliSuite("3.3.3") {
| ^^
|""".stripMargin,
)
_ = server.server.indexingPromise = Promise[Unit]()
_ <- server.didSave("Main.scala") { text =>
text.replace("// >", "//>")
}
_ <- server.server.indexingPromise.future
// cause another compilation to wait on workspace reload, the previous gets cancelled
_ <- server.didSave("Main.scala")(identity)
_ = assertEquals(
Expand Down

0 comments on commit 007da1d

Please sign in to comment.