Skip to content

Commit

Permalink
Merge pull request #3006 from adpi2/sbt-server-tests-2
Browse files Browse the repository at this point in the history
Alternative version of #2999: Add more tests on using sbt as the build server
  • Loading branch information
adpi2 authored Aug 10, 2021
2 parents 250cf2f + c2f9869 commit 0edb78e
Show file tree
Hide file tree
Showing 88 changed files with 2,001 additions and 1,638 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ lazy val `sbt-metals` = project
"semanticdbVersion" -> V.semanticdb,
"supportedScala2Versions" -> V.scala2Versions
),
addSbtPlugin("ch.epfl.scala" % "sbt-debug-adapter" % "1.1.2")
addSbtPlugin("ch.epfl.scala" % "sbt-debug-adapter" % "1.1.3")
)
.enablePlugins(BuildInfoPlugin)
.disablePlugins(ScalafixPlugin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ object Messages {
object ImportBuildChanges {
def yes: MessageActionItem =
new MessageActionItem("Import changes")
def notNow: MessageActionItem = Messages.notNow
def params(buildToolName: String): ShowMessageRequestParams = {
val params = new ShowMessageRequestParams()
params.setMessage(s"$buildToolName build needs to be re-imported")
Expand All @@ -137,6 +138,7 @@ object Messages {

object ImportBuild {
def yes = new MessageActionItem("Import build")
def notNow: MessageActionItem = Messages.notNow
def params(buildToolName: String): ShowMessageRequestParams = {
val params = new ShowMessageRequestParams()
params.setMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,7 @@ class MetalsLanguageServer(
Future.successful(BuildChange.None)
}
_ = {
tables.dismissedNotifications.ImportChanges.reset()
treeView.init()
}
} yield result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MultipleBuildFilesLspSuite
test("basic") {
cleanWorkspace()
for {
_ <- server.initialize(
_ <- initialize(
s"""|/build.sbt
|scalaVersion := "${V.scala212}"
|/build.sc
Expand Down
7 changes: 4 additions & 3 deletions tests/slow/src/test/scala/tests/SymlinkedProjectSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import scala.meta.internal.metals.MetalsEnrichments._
import scala.meta.internal.metals.{BuildInfo => V}
import scala.meta.io.AbsolutePath

class SymlinkedProjectSuite extends BaseLspSuite("symlinked-project") {
class SymlinkedProjectSuite
extends BaseLspSuite("symlinked-project", BloopImportInitializer) {
test("definitions-from-other-file") {
for {
_ <- server.initialize(
_ <- initialize(
s"""|/project/build.properties
|sbt.version=${V.sbtVersion}
|
Expand Down Expand Up @@ -48,7 +49,7 @@ class SymlinkedProjectSuite extends BaseLspSuite("symlinked-project") {
|""".stripMargin
)
for {
_ <- server.initialize(
_ <- initialize(
s"""|/project/build.properties
|sbt.version=${V.sbtVersion}
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Ammonite212Suite extends tests.BaseAmmoniteSuite(V.ammonite212) {

test("global-version-fallback") {
for {
_ <- server.initialize(
_ <- initialize(
s"""
|/metals.json
|{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CompletionCrossLspSuite
test("serializable-2.13") {
cleanWorkspace()
for {
_ <- server.initialize(
_ <- initialize(
s"""/metals.json
|{
| "a": { "scalaVersion": "${V.scala213}" }
Expand Down
117 changes: 9 additions & 108 deletions tests/slow/src/test/scala/tests/feature/CrossDebugSuite.scala
Original file line number Diff line number Diff line change
@@ -1,110 +1,11 @@
package tests.feature

import scala.meta.internal.metals.{BuildInfo => V}

import tests.BaseDapSuite

class CrossDebugSuite extends BaseDapSuite("cross-debug") {

override def scalaVersion: String = V.scala3

assertBreakpoints(
"outer",
main = Some("a.helloWorld")
)(
source = """|/a/src/main/scala/a/Main.scala
|package a
|
|@main
|def helloWorld(): Unit = {
|>>println("Hello world")
| System.exit(0)
|}
|
|""".stripMargin
)

assertBreakpoints(
"unapply",
main = Some("a.helloWorld")
)(
source = """|/a/src/main/scala/a/Main.scala
|package a
|
|@main
|def helloWorld(): Unit = {
| object Even {
|>> def unapply(s: String): Boolean = s.size % 2 == 0
| }
|
| "even" match {
| case Even() =>
| case _ =>
| }
| System.exit(0)
|}
|
|""".stripMargin
)

assertBreakpoints(
"object-in-toplevel-method",
main = Some("a.helloWorld")
)(
source = """|/a/src/main/scala/a/Main.scala
|package a
|
|@main
|def helloWorld(): Unit = {
| object Hello{
| def run() = {
|>> println("Hello world")
| }
| }
| Hello.run()
| System.exit(0)
|}
|
|
|""".stripMargin
)

assertBreakpoints(
"optional-braces",
main = Some("a.hello")
)(
source = """|/a/src/main/scala/a/Main.scala
|package a
|
|@main
|def hello(): Unit =
| greet("Alice")
| System.exit(0)
|
|def greet(name: String) =
|>>val message = s"Hello, $name!"
|>>println(message)
|
|""".stripMargin
)

assertBreakpoints(
"optional-braces-main",
main = Some("a.hello")
)(
source = """|/a/src/main/scala/a/Main.scala
|package a
|
|@main
|def hello(): Unit =
|>>greet("Alice")
|>>System.exit(0)
|
|def greet(name: String) =
| val message = s"Hello, $name!"
| println(message)
|
|""".stripMargin
)

}
import tests.QuickBuildInitializer
import tests.QuickBuildLayout

class CrossDebugSuite
extends BaseCrossDebugSuite(
"cross-debug",
QuickBuildInitializer,
QuickBuildLayout
)
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DefinitionCrossLspSuite
test("underscore") {
cleanDatabase()
for {
_ <- server.initialize(
_ <- initialize(
s"""
|/metals.json
|{
Expand Down Expand Up @@ -65,7 +65,7 @@ class DefinitionCrossLspSuite
def basicDefinitionTest(scalaVersion: String): Future[Unit] = {
cleanDatabase()
for {
_ <- server.initialize(
_ <- initialize(
s"""
|/metals.json
|{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FoldingCrossLspSuite extends BaseLspSuite("foldingRange-cross") {

test("base-213") {
for {
_ <- server.initialize(
_ <- initialize(
s"""|
|/metals.json
|{
Expand Down Expand Up @@ -44,7 +44,7 @@ class FoldingCrossLspSuite extends BaseLspSuite("foldingRange-cross") {

test("source-3") {
for {
_ <- server.initialize(
_ <- initialize(
s"""|
|/metals.json
|{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SyntaxErrorLspSuite extends BaseLspSuite("syntax-error") {
}

for {
_ <- server.initialize(
_ <- initialize(
s"""
|/metals.json
|{"a": {}}
Expand All @@ -49,7 +49,7 @@ class SyntaxErrorLspSuite extends BaseLspSuite("syntax-error") {

test("basic") {
for {
_ <- server.initialize(
_ <- initialize(
"""|
|/metals.json
|{"a": {}}
Expand Down Expand Up @@ -93,7 +93,7 @@ class SyntaxErrorLspSuite extends BaseLspSuite("syntax-error") {

test("mix1") {
for {
_ <- server.initialize(
_ <- initialize(
"""|
|/metals.json
|{"a": {}}
Expand Down Expand Up @@ -129,7 +129,7 @@ class SyntaxErrorLspSuite extends BaseLspSuite("syntax-error") {

test("mix2") {
for {
_ <- server.initialize(
_ <- initialize(
"""|
|/metals.json
|{"a": {}}
Expand Down Expand Up @@ -163,7 +163,7 @@ class SyntaxErrorLspSuite extends BaseLspSuite("syntax-error") {

test("no-build-tool") {
for {
_ <- server.initialize(
_ <- initialize(
"""
|/A.scala
|object A { val x = }
Expand All @@ -183,7 +183,7 @@ class SyntaxErrorLspSuite extends BaseLspSuite("syntax-error") {

test("unclosed-literal") {
for {
_ <- server.initialize(
_ <- initialize(
"""
|/metals.json
|{"a": {}}
Expand Down Expand Up @@ -321,7 +321,7 @@ class SyntaxErrorLspSuite extends BaseLspSuite("syntax-error") {
test("literal-types") {
cleanWorkspace()
for {
_ <- server.initialize(
_ <- initialize(
s"""
|/metals.json
|{"a": { "scalaVersion": "${V.scala213}" }}
Expand All @@ -346,7 +346,7 @@ class SyntaxErrorLspSuite extends BaseLspSuite("syntax-error") {
.sortWith(_ > _)
.head
for {
_ <- server.initialize(
_ <- initialize(
s"""
|/metals.json
|{"a": { "scalaVersion": "$latestScala3" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Worksheet213LspSuite extends tests.BaseWorksheetLspSuite(V.scala213) {

test("literals") {
for {
_ <- server.initialize(
_ <- initialize(
s"""
|/metals.json
|{"a": {"scalaVersion": "${V.scala213}"}}
Expand Down
Loading

0 comments on commit 0edb78e

Please sign in to comment.