Skip to content

Commit

Permalink
chore: Bring back cross tests for Scala 2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
jkciesluk authored and tgodzik committed Nov 15, 2023
1 parent c68474d commit 653c799
Show file tree
Hide file tree
Showing 91 changed files with 1,997 additions and 1,786 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ jobs:
command: bin/test.sh 'slow/testOnly -- tests.gradle.*'
name: Gradle MacOS integration
os: macOS-latest
java: "17"
- type: sbt
command: bin/test.sh 'slow/testOnly -- tests.sbt.*'
name: Sbt integration
os: ubuntu-latest
java: "17"
- type: sbt-metals jdk8
command: bin/test.sh sbt-metals/scripted
name: Sbt-metals/scripted jdk8
Expand All @@ -79,52 +81,68 @@ jobs:
command: bin/test.sh 'slow/testOnly -- tests.maven.*'
name: Maven integration
os: ubuntu-latest
java: "17"
- type: gradle
command: bin/test.sh 'slow/testOnly -- tests.gradle.*'
name: Gradle integration
os: ubuntu-latest
java: "17"
- type: mill
command: bin/test.sh 'slow/testOnly -- tests.mill.*'
name: Mill integration
os: ubuntu-latest
java: "17"
- type: scalacli
command: bin/test.sh 'slow/testOnly -- tests.scalacli.*'
name: Scala CLI integration
os: ubuntu-latest
java: "17"
- type: feature
command: bin/test.sh 'slow/testOnly -- tests.feature.*'
name: LSP integration tests
os: ubuntu-latest
java: "17"
- type: cross
command: sbt +cross/test
name: Scala cross tests
os: ubuntu-latest
java: "17"
- type: mtags-java
command: sbt javapc/test
name: Scala javapc tests
os: ubuntu-latest
java: "17"
- type: cross-test-nightly
command: sbt cross-test-latest-nightly
name: Scala3 latest NIGHTLY cross test
os: ubuntu-latest
java: "17"
- type: cross-test-2-11
command: sbt cross-test-2-11
name: Scala 2.11 cross tests
os: ubuntu-latest
java: "8"
- type: scalafix
command: sbt scalafixCheck docs/docusaurusCreateSite
name: Scalafix and docs
os: ubuntu-latest
java: "17"
- type: scalafmt
command: ./bin/scalafmt --test
name: Formatting
os: ubuntu-latest
java: "17"
- type: MiMa
command: sbt interfaces/mimaReportBinaryIssues
name: MiMa
os: ubuntu-latest
java: "17"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: "17"
java-version: ${{ matrix.java }}
cache: 'sbt'
- name: ${{ matrix.command }}
run: ${{ matrix.command }}
Expand Down
6 changes: 6 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ fileOverride {
"glob:**/mtags*/**" {
trailingCommas = never
}
"glob:**/tests/cross/src/**" {
trailingCommas = never
}
"glob:**/mtest/**" {
trailingCommas = never
}
}
3 changes: 3 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ commands ++= Seq(
s
}
},
Command.command("cross-test-2-11") { s =>
crossTestDyn(s, V.scala211)
},
Command.single("test-mtags-dyn") { (s, scalaV) =>
crossTestDyn(s, scalaV)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ class SignatureHelpProvider(val compiler: MetalsGlobal) {
shortenedNames
)
}
if (activeSignature == null) {
activeSignature = 0
}
val mainSignature = infos(activeSignature)
val deduplicated = infos
.filter { sig =>
Expand Down
18 changes: 9 additions & 9 deletions tests/cross/src/main/scala/tests/BaseAutoImportsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ trait BaseAutoImportsSuite extends BaseCodeActionSuite {
name: String,
original: String,
expected: String,
compat: Map[String, String] = Map.empty,
compat: Map[String, String] = Map.empty
)(implicit loc: Location): Unit =
test(name) {
val imports = getAutoImports(original, "A.scala")
val obtained = imports.map(_.packageName()).mkString("\n")
assertNoDiff(
obtained,
getExpected(expected, compat, scalaVersion),
getExpected(expected, compat, scalaVersion)
)
}

Expand All @@ -35,7 +35,7 @@ trait BaseAutoImportsSuite extends BaseCodeActionSuite {
expected: String,
selection: Int = 0,
filename: String = "A.scala",
compat: Map[String, String] = Map.empty,
compat: Map[String, String] = Map.empty
)(implicit
loc: Location
): Unit =
Expand All @@ -46,7 +46,7 @@ trait BaseAutoImportsSuite extends BaseCodeActionSuite {
original: String,
expected: String,
selection: Int = 0,
compat: Map[String, String] = Map.empty,
compat: Map[String, String] = Map.empty
)(implicit
loc: Location
): Unit =
Expand All @@ -56,7 +56,7 @@ trait BaseAutoImportsSuite extends BaseCodeActionSuite {
original,
expected,
selection,
compat,
compat
)

def checkEditSelection(
Expand All @@ -65,7 +65,7 @@ trait BaseAutoImportsSuite extends BaseCodeActionSuite {
original: String,
expected: String,
selection: Int,
compat: Map[String, String] = Map.empty,
compat: Map[String, String] = Map.empty
)(implicit
loc: Location
): Unit =
Expand All @@ -80,7 +80,7 @@ trait BaseAutoImportsSuite extends BaseCodeActionSuite {

def getAutoImports(
original: String,
filename: String,
filename: String
): List[AutoImportsResult] = {
val (code, symbol, offset) = params(original)
val result = presentationCompiler
Expand All @@ -90,9 +90,9 @@ trait BaseAutoImportsSuite extends BaseCodeActionSuite {
Paths.get(filename).toUri(),
code,
offset,
cancelToken,
cancelToken
),
isExtensionMethods,
isExtensionMethods
)
.get()
result.asScala.toList
Expand Down
32 changes: 16 additions & 16 deletions tests/cross/src/main/scala/tests/BaseCompletionSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ abstract class BaseCompletionSuite extends BasePCSuite {

private def getItems(
original: String,
filename: String = "A.scala",
filename: String = "A.scala"
): Seq[CompletionItem] = {
val (code, offset) = params(original, filename)
val result = resolvedCompletions(
CompilerOffsetParams(
Paths.get(filename).toUri(),
code,
offset,
cancelToken,
cancelToken
)
)
result.getItems.asScala
Expand All @@ -62,7 +62,7 @@ abstract class BaseCompletionSuite extends BasePCSuite {
def checkItems(
name: TestOptions,
original: String,
fn: Seq[CompletionItem] => Boolean,
fn: Seq[CompletionItem] => Boolean
)(implicit loc: Location): Unit = {
test(name) { assert(fn(getItems(original))) }
}
Expand Down Expand Up @@ -91,7 +91,7 @@ abstract class BaseCompletionSuite extends BasePCSuite {
assertSingleItem: Boolean = true,
filter: String => Boolean = _ => true,
command: Option[String] = None,
compat: Map[String, String] = Map.empty,
compat: Map[String, String] = Map.empty
)(implicit loc: Location): Unit = {
val compatTemplate = compat.map { case (key, value) =>
key -> template.replace("___", value)
Expand All @@ -104,7 +104,7 @@ abstract class BaseCompletionSuite extends BasePCSuite {
assertSingleItem = assertSingleItem,
filter = filter,
command = command,
compat = compatTemplate,
compat = compatTemplate
)
}

Expand All @@ -131,7 +131,7 @@ abstract class BaseCompletionSuite extends BasePCSuite {
command: Option[String] = None,
compat: Map[String, String] = Map.empty,
itemIndex: Int = 0,
filename: String = "A.scala",
filename: String = "A.scala"
)(implicit loc: Location): Unit = {
test(name) {
val items =
Expand All @@ -148,15 +148,15 @@ abstract class BaseCompletionSuite extends BasePCSuite {
val obtained = TextEdits.applyEdits(code, item)
assertNoDiff(
obtained,
getExpected(expected, compat, scalaVersion),
getExpected(expected, compat, scalaVersion)
)
if (filterText.nonEmpty) {
assertNoDiff(item.getFilterText, filterText, "Invalid filter text")
}
assertNoDiff(
Option(item.getCommand).fold("")(_.getCommand),
command.getOrElse(""),
"Invalid command",
"Invalid command"
)
}
}
Expand All @@ -175,7 +175,7 @@ abstract class BaseCompletionSuite extends BasePCSuite {
expected: String,
compat: Map[String, String] = Map.empty,
topLines: Option[Int] = None,
includeDetail: Boolean = false,
includeDetail: Boolean = false
)(implicit loc: Location): Unit = {
test(name) {
val baseItems = getItems(original)
Expand All @@ -196,7 +196,7 @@ abstract class BaseCompletionSuite extends BasePCSuite {
.mkString("\n")
assertNoDiff(
obtained,
getExpected(expected, compat, scalaVersion),
getExpected(expected, compat, scalaVersion)
)
}
}
Expand Down Expand Up @@ -235,7 +235,7 @@ abstract class BaseCompletionSuite extends BasePCSuite {
includeDetail: Boolean = true,
filename: String = "A.scala",
filter: String => Boolean = _ => true,
enablePackageWrap: Boolean = true,
enablePackageWrap: Boolean = true
)(implicit loc: Location): Unit = {
test(name) {
val out = new StringBuilder()
Expand Down Expand Up @@ -280,19 +280,19 @@ abstract class BaseCompletionSuite extends BasePCSuite {
assertNoDiff(
sortLines(
stableOrder,
postProcessObtained(trimTrailingSpace(out.toString())),
postProcessObtained(trimTrailingSpace(out.toString()))
),
sortLines(
stableOrder,
getExpected(expected, compat, scalaVersion),
),
getExpected(expected, compat, scalaVersion)
)
)
if (filterText.nonEmpty) {
filteredItems.foreach { item =>
assertNoDiff(
item.getFilterText,
filterText,
s"Invalid filter text for item:\n$item",
s"Invalid filter text for item:\n$item"
)
}
}
Expand All @@ -310,7 +310,7 @@ abstract class BaseCompletionSuite extends BasePCSuite {
s.replace("equals(obj: Any)", "equals(obj: Object)")
.replace(
"singletonList[T](o: T)",
"singletonList[T <: Object](o: T)",
"singletonList[T <: Object](o: T)"
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class BaseDocumentHighlightSuite extends BasePCSuite with RangeReplace {

def check(
name: TestOptions,
original: String,
// compat: Map[String, String] = Map.empty,
original: String
// compat: Map[String, String] = Map.empty
)(implicit location: Location): Unit =
test(name) {

Expand All @@ -30,7 +30,7 @@ class BaseDocumentHighlightSuite extends BasePCSuite with RangeReplace {
URI.create("file:/Highlight.scala"),
code,
offset,
EmptyCancelToken,
EmptyCancelToken
)
)
.get()
Expand All @@ -41,13 +41,13 @@ class BaseDocumentHighlightSuite extends BasePCSuite with RangeReplace {

assertEquals(
renderHighlightsAsString(base, highlights),
expected,
expected
)

}
private def compareHighlights(
h1: DocumentHighlight,
h2: DocumentHighlight,
h2: DocumentHighlight
) = {
val r1 = h1.getRange().getStart()
val r2 = h2.getRange().getStart()
Expand Down
10 changes: 5 additions & 5 deletions tests/cross/src/main/scala/tests/BaseExtractMethodSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BaseExtractMethodSuite extends BaseCodeActionSuite {
name: TestOptions,
original: String,
expected: String,
compat: Map[String, String] = Map.empty,
compat: Map[String, String] = Map.empty
)(implicit location: Location): Unit =
test(name) {
val (edits, code) = getAutoImplement(original)
Expand All @@ -27,7 +27,7 @@ class BaseExtractMethodSuite extends BaseCodeActionSuite {

def getAutoImplement(
original: String,
filename: String = "file:/A.scala",
filename: String = "file:/A.scala"
): (List[l.TextEdit], String) = {
val withoutExtractionPos = original.replace("@@", "")
val onlyRangeClose = withoutExtractionPos
Expand All @@ -37,19 +37,19 @@ class BaseExtractMethodSuite extends BaseCodeActionSuite {
URI.create(filename),
code,
original.indexOf("@@"),
cancelToken,
cancelToken
)
val rangeParams = CompilerRangeParams(
URI.create(filename),
code,
withoutExtractionPos.indexOf("<<"),
onlyRangeClose.indexOf(">>"),
cancelToken,
cancelToken
)
val result = presentationCompiler
.extractMethod(
rangeParams,
extractionPos,
extractionPos
)
.get()
(result.asScala.toList, code)
Expand Down
Loading

0 comments on commit 653c799

Please sign in to comment.