Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Jan 7, 2025
1 parent 42b3353 commit db7ff72
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions integration/ide/bsp-server/src/BspServerTestUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,30 @@ object BspServerTestUtil {
value,
implicitly[ClassTag[T]].runtimeClass
)
lazy val expectedJsonStr = expectedValueOpt match{
case Some(v) => gson.toJson(v, implicitly[ClassTag[T]].runtimeClass)
case None => ""
}
if (updateSnapshots) {
System.err.println(if (exists) s"Updating $snapshotPath" else s"Writing $snapshotPath")
os.write.over(snapshotPath, normalizeLocalValues(jsonStr), createFolders = true)
} else {
System.err.println("Expected JSON:")
System.err.println(jsonStr)
Predef.assert(
false,
if (exists)
if (exists) {
val diff = os.call((
"git", "diff",
os.temp(jsonStr, suffix = "jsonStr"),
os.temp(expectedJsonStr, suffix = "expectedJsonStr")
))
s"""Error: value differs from snapshot in $snapshotPath
|
|You might want to set BspServerTestUtil.updateSnapshots to true,
|run this test again, and commit the updated test data files.
|
|$diff
|""".stripMargin
else s"Error: no snapshot found at $snapshotPath"
} else s"Error: no snapshot found at $snapshotPath"
)
}
} else if (updateSnapshots) {
Expand Down

0 comments on commit db7ff72

Please sign in to comment.