Skip to content

Commit

Permalink
Backport "improvement: Make sure Scala CLI tests are less flaky" to L…
Browse files Browse the repository at this point in the history
…TS (#22118)

Backports #21570 to the 3.3.5.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Dec 4, 2024
2 parents a2656e7 + e1697b3 commit 977d6db
Showing 1 changed file with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.junit.Ignore
class CompletionScalaCliSuite extends BaseCompletionSuite:

@Test def `simple` =
check(
checkSubset(
"""|//> using lib "io.cir@@
|package A
|""".stripMargin,
Expand All @@ -30,24 +30,25 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
|//> using lib io.circe::circe-core_native0.4
|package A
|""".stripMargin,
assertSingleItem = false
assertSingleItem = false,
filter = _.contains("circe-core_native0.4")
)

@Test def `version-sort` =
check(
checkSubset(
"""|//> using dep "com.lihaoyi::pprint:0.7@@"
|package A
|""".stripMargin,
"""|0.7.3
|0.7.2
|0.7.1
|0.7.0
|""".stripMargin,
|""".stripMargin
)

@Ignore
@Test def `single-colon` =
check(
checkSubset(
"""|//> using lib "io.circe:circe-core_na@@
|package A
|""".stripMargin,
Expand All @@ -59,7 +60,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:

@Ignore
@Test def `version` =
check(
checkSubset(
"""|//> using lib "io.circe::circe-core_sjs1:0.14.10@@"
|package A
|""".stripMargin,
Expand All @@ -76,11 +77,12 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
"""|//> using lib "io.circe::circe-core_sjs1:0.14.10"
|package A
|""".stripMargin,
filter = _.endsWith("0.14.10")
)

@Ignore
@Test def `multiple-libs` =
check(
checkSubset(
"""|//> using lib "io.circe::circe-core:0.14.0", "io.circe::circe-core_na@@"
|package A
|""".stripMargin,
Expand All @@ -89,7 +91,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:

@Ignore
@Test def `script` =
check(
checkSubset(
scriptWrapper(
"""|//> using lib "io.circe:circe-core_na@@
|
Expand All @@ -105,15 +107,15 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
)

@Test def `closing-quote` =
check(
checkSubset(
"""|//> using lib "io.circe::circe-core:0.14.0"@@
|package A
|""".stripMargin,
""
)

@Test def `whitespace` =
check(
checkSubset(
"""|//> using lib "io.circe::circe-co @@
|package A
|""".stripMargin,
Expand All @@ -132,7 +134,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
)

@Test def `dep` =
check(
checkSubset(
"""|//> using dep "io.cir@@
|package A
|""".stripMargin,
Expand All @@ -142,13 +144,29 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:

@Ignore
@Test def `multiple-deps2` =
check(
checkSubset(
"""|//> using libs "io.circe::circe-core:0.14.0", "io.circe::circe-core_na@@"
|package A
|""".stripMargin,
"circe-core_native0.4"
)

def checkSubset(
original: String,
expected: String,
filename: String = "A.scala",
enablePackageWrap: Boolean = true
) = {
val expectedAtLeast = expected.linesIterator.toSet
check(
original,
expected,
filter = expectedAtLeast,
filename = filename,
enablePackageWrap = enablePackageWrap
)
}

private def scriptWrapper(code: String, filename: String): String =
// Vaguely looks like a scala file that ScalaCLI generates
// from a sc file.
Expand Down

0 comments on commit 977d6db

Please sign in to comment.