Skip to content

Commit

Permalink
chore: Add tests for Bazel 7
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Aug 29, 2024
1 parent 8e02ab8 commit 0d96d42
Showing 1 changed file with 51 additions and 48 deletions.
99 changes: 51 additions & 48 deletions tests/slow/src/test/scala/tests/bazel/BazelLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class BazelLspSuite
val buildTool: BazelBuildTool = BazelBuildTool(() => userConfig, workspace)

val bazelVersion = "6.4.0"
val bazel7Version = "7.3.0"

def bazelBspConfig: AbsolutePath = workspace.resolve(".bsp/bazelbsp.json")

Expand All @@ -38,55 +39,57 @@ class BazelLspSuite
val importMessage: String =
GenerateBspAndConnect.params("bazel", "bazelbsp").getMessage()

test("basic") {
cleanWorkspace()
for {
_ <- initialize(
BazelBuildLayout(workspaceLayout, V.bazelScalaVersion, bazelVersion)
)
_ = assertNoDiff(
client.workspaceMessageRequests,
List(
importMessage
).mkString("\n"),
)
_ = assert(bazelBspConfig.exists)
_ = client.messageRequests.clear() // restart
_ = assertStatus(_.isInstalled)
_ = assertNoDiff(client.workspaceDiagnostics, "")
_ <- server.didChange("WORKSPACE")(_ + "\n# comment")
_ <- server.didSave("WORKSPACE")(identity)
// Comment changes do not trigger "re-import project" request
_ = assertNoDiff(client.workspaceMessageRequests, "")
_ <- server.didChange("Hello.scala") { text =>
text.replace("def hello: String", "def hello: Int")
}
_ <- server.didSave("Hello.scala")(identity)
_ = assertNoDiff(
client.workspaceDiagnostics,
"""|Hello.scala:4:20: error: type mismatch;
| found : String("Hello")
| required: Int
| def hello: Int = "Hello"
| ^
| def hello: Int = "Hello"
| ^
|""".stripMargin,
)
_ <- server.didChange(s"BUILD") { text =>
text.replace("\"hello\"", "\"hello1\"")
for (bazelVersion <- List(bazelVersion, bazel7Version)) {
test(s"basic-$bazelVersion") {
cleanWorkspace()
for {
_ <- initialize(
BazelBuildLayout(workspaceLayout, V.bazelScalaVersion, bazelVersion)
)
_ = assertNoDiff(
client.workspaceMessageRequests,
List(
importMessage
).mkString("\n"),
)
_ = assert(bazelBspConfig.exists)
_ = client.messageRequests.clear() // restart
_ = assertStatus(_.isInstalled)
_ = assertNoDiff(client.workspaceDiagnostics, "")
_ <- server.didChange("WORKSPACE")(_ + "\n# comment")
_ <- server.didSave("WORKSPACE")(identity)
// Comment changes do not trigger "re-import project" request
_ = assertNoDiff(client.workspaceMessageRequests, "")
_ <- server.didChange("Hello.scala") { text =>
text.replace("def hello: String", "def hello: Int")
}
_ <- server.didSave("Hello.scala")(identity)
_ = assertNoDiff(
client.workspaceDiagnostics,
"""|Hello.scala:4:20: error: type mismatch;
| found : String("Hello")
| required: Int
| def hello: Int = "Hello"
| ^
| def hello: Int = "Hello"
| ^
|""".stripMargin,
)
_ <- server.didChange(s"BUILD") { text =>
text.replace("\"hello\"", "\"hello1\"")
}
_ = assertNoDiff(client.workspaceMessageRequests, "")
_ = client.generateBspAndConnect = GenerateBspAndConnect.yes
_ <- server.didSave(s"BUILD")(identity)
} yield {
assertNoDiff(
client.workspaceMessageRequests,
List(
importBuildChangesMessage
).mkString("\n"),
)
server.assertBuildServerConnection()
}
_ = assertNoDiff(client.workspaceMessageRequests, "")
_ = client.generateBspAndConnect = GenerateBspAndConnect.yes
_ <- server.didSave(s"BUILD")(identity)
} yield {
assertNoDiff(
client.workspaceMessageRequests,
List(
importBuildChangesMessage
).mkString("\n"),
)
server.assertBuildServerConnection()
}
}

Expand Down

0 comments on commit 0d96d42

Please sign in to comment.