Skip to content

Commit 977d6db

Browse files
Backport "improvement: Make sure Scala CLI tests are less flaky" to LTS (#22118)
Backports #21570 to the 3.3.5. PR submitted by the release tooling. [skip ci]
2 parents a2656e7 + e1697b3 commit 977d6db

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionScalaCliSuite.scala

+30-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.junit.Ignore
88
class CompletionScalaCliSuite extends BaseCompletionSuite:
99

1010
@Test def `simple` =
11-
check(
11+
checkSubset(
1212
"""|//> using lib "io.cir@@
1313
|package A
1414
|""".stripMargin,
@@ -30,24 +30,25 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
3030
|//> using lib io.circe::circe-core_native0.4
3131
|package A
3232
|""".stripMargin,
33-
assertSingleItem = false
33+
assertSingleItem = false,
34+
filter = _.contains("circe-core_native0.4")
3435
)
3536

3637
@Test def `version-sort` =
37-
check(
38+
checkSubset(
3839
"""|//> using dep "com.lihaoyi::pprint:0.7@@"
3940
|package A
4041
|""".stripMargin,
4142
"""|0.7.3
4243
|0.7.2
4344
|0.7.1
4445
|0.7.0
45-
|""".stripMargin,
46+
|""".stripMargin
4647
)
4748

4849
@Ignore
4950
@Test def `single-colon` =
50-
check(
51+
checkSubset(
5152
"""|//> using lib "io.circe:circe-core_na@@
5253
|package A
5354
|""".stripMargin,
@@ -59,7 +60,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
5960

6061
@Ignore
6162
@Test def `version` =
62-
check(
63+
checkSubset(
6364
"""|//> using lib "io.circe::circe-core_sjs1:0.14.10@@"
6465
|package A
6566
|""".stripMargin,
@@ -76,11 +77,12 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
7677
"""|//> using lib "io.circe::circe-core_sjs1:0.14.10"
7778
|package A
7879
|""".stripMargin,
80+
filter = _.endsWith("0.14.10")
7981
)
8082

8183
@Ignore
8284
@Test def `multiple-libs` =
83-
check(
85+
checkSubset(
8486
"""|//> using lib "io.circe::circe-core:0.14.0", "io.circe::circe-core_na@@"
8587
|package A
8688
|""".stripMargin,
@@ -89,7 +91,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
8991

9092
@Ignore
9193
@Test def `script` =
92-
check(
94+
checkSubset(
9395
scriptWrapper(
9496
"""|//> using lib "io.circe:circe-core_na@@
9597
|
@@ -105,15 +107,15 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
105107
)
106108

107109
@Test def `closing-quote` =
108-
check(
110+
checkSubset(
109111
"""|//> using lib "io.circe::circe-core:0.14.0"@@
110112
|package A
111113
|""".stripMargin,
112114
""
113115
)
114116

115117
@Test def `whitespace` =
116-
check(
118+
checkSubset(
117119
"""|//> using lib "io.circe::circe-co @@
118120
|package A
119121
|""".stripMargin,
@@ -132,7 +134,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
132134
)
133135

134136
@Test def `dep` =
135-
check(
137+
checkSubset(
136138
"""|//> using dep "io.cir@@
137139
|package A
138140
|""".stripMargin,
@@ -142,13 +144,29 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
142144

143145
@Ignore
144146
@Test def `multiple-deps2` =
145-
check(
147+
checkSubset(
146148
"""|//> using libs "io.circe::circe-core:0.14.0", "io.circe::circe-core_na@@"
147149
|package A
148150
|""".stripMargin,
149151
"circe-core_native0.4"
150152
)
151153

154+
def checkSubset(
155+
original: String,
156+
expected: String,
157+
filename: String = "A.scala",
158+
enablePackageWrap: Boolean = true
159+
) = {
160+
val expectedAtLeast = expected.linesIterator.toSet
161+
check(
162+
original,
163+
expected,
164+
filter = expectedAtLeast,
165+
filename = filename,
166+
enablePackageWrap = enablePackageWrap
167+
)
168+
}
169+
152170
private def scriptWrapper(code: String, filename: String): String =
153171
// Vaguely looks like a scala file that ScalaCLI generates
154172
// from a sc file.

0 commit comments

Comments
 (0)