@@ -13,7 +13,6 @@ import scala.util.Try
13
13
import scala .meta .internal .io .FileIO
14
14
import scala .meta .io .AbsolutePath
15
15
16
- import buildinfo .RulesBuildInfo
17
16
import org .scalatest .funsuite .AnyFunSuite
18
17
import scalafix .interfaces .ScalafixArguments
19
18
import scalafix .interfaces .ScalafixDiagnostic
@@ -26,16 +25,15 @@ import scalafix.internal.rule.RemoveUnusedConfig
26
25
import scalafix .internal .tests .utils .SkipWindows
27
26
import scalafix .test .StringFS
28
27
import scalafix .testkit .DiffAssertions
28
+ import scalafix .tests .BuildInfo
29
29
import scalafix .tests .core .Classpaths
30
30
import scalafix .tests .util .ScalaVersions
31
31
import scalafix .tests .util .compat .CompatSemanticdb
32
32
import scalafix .v1 .SemanticRule
33
33
34
34
class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
35
- val scalaBinaryVersion : String =
36
- RulesBuildInfo .scalaVersion.split('.' ).take(2 ).mkString(" ." )
37
- val scalaVersion = RulesBuildInfo .scalaVersion
38
- val removeUnused : String =
35
+ private val scalaVersion = BuildInfo .scalaVersion
36
+ private val removeUnused : String =
39
37
if (ScalaVersions .isScala213)
40
38
" -Wunused:imports"
41
39
else " -Ywarn-unused-import"
@@ -66,16 +64,24 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
66
64
val main : Path = src.resolve(" Main.scala" )
67
65
val relativePath : Path = cwd.relativize(main)
68
66
67
+ val specificScalacOption2 : Seq [String ] =
68
+ if (! ScalaVersions .isScala3)
69
+ Seq (removeUnused)
70
+ else Nil
71
+
69
72
val scalacOptions : Array [String ] = Array [String ](
70
- removeUnused,
71
73
" -classpath" ,
72
74
s " ${scalaLibrary.mkString(" :" )}" ,
73
75
" -d" ,
74
76
d.toString,
75
77
main.toString
76
- ) ++ CompatSemanticdb .scalacOptions(src, target)
78
+ ) ++ specificScalacOption2 ++ CompatSemanticdb .scalacOptions(src, target)
77
79
78
80
test(" ScalafixArguments.evaluate with a semantic rule" , SkipWindows ) {
81
+ // Todo(i1680): this is an integration test that uses many non supported rules in scala 3.
82
+ // Add a more simple test for scala 3. For now we ignore for Scala 3.
83
+ if (ScalaVersions .isScala3) cancel()
84
+
79
85
val _ = CompatSemanticdb .runScalac(scalacOptions)
80
86
val result = api
81
87
.withRules(
@@ -155,6 +161,8 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
155
161
}
156
162
157
163
test(" ScalafixArguments.evaluate getting StaleSemanticdb" , SkipWindows ) {
164
+ // Todo(i1680): We need a semanticRule in scala 3.
165
+ if (ScalaVersions .isScala3) cancel()
158
166
val _ = CompatSemanticdb .runScalac(scalacOptions)
159
167
val args = api
160
168
.withRules(
@@ -188,6 +196,8 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
188
196
" ScalafixArguments.evaluate doesn't take into account withMode and withMainCallback" ,
189
197
SkipWindows
190
198
) {
199
+ // Todo(i1680): We need a semanticRule in scala 3.
200
+ if (ScalaVersions .isScala3) cancel()
191
201
val _ = CompatSemanticdb .runScalac(scalacOptions)
192
202
val contentBeforeEvaluation =
193
203
FileIO .slurp(AbsolutePath (main), StandardCharsets .UTF_8 )
@@ -341,6 +351,8 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
341
351
}
342
352
343
353
test(" Scalafix-evaluation-error-messages: missing semanticdb" , SkipWindows ) {
354
+ // Todo(i1680): We need a semanticRule in scala 3.
355
+ if (ScalaVersions .isScala3) cancel()
344
356
val eval = api
345
357
.withPaths(Seq (main).asJava)
346
358
.withRules(List (" ExplicitResultTypes" ).asJava)
@@ -433,7 +445,9 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
433
445
test(" Scala 3 style wildcard import" , SkipWindows ) {
434
446
// https://github.com/scalacenter/scalafix/issues/1663
435
447
436
- if (scala.util.Properties .versionNumberString.startsWith(" 2.11" )) {
448
+ // Todo(i1680): Add another test for scala 3 that doesn't uses removeUnused or
449
+ // at least remove the if when removeUnused is supported in scala 3
450
+ if (ScalaVersions .isScala211 || ScalaVersions .isScala3) {
437
451
cancel()
438
452
}
439
453
@@ -510,4 +524,12 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
510
524
511
525
def scalaLibrary : Seq [AbsolutePath ] = Classpaths .scalaLibrary.entries
512
526
527
+ def scalacOptions (
528
+ scalaVersion : String = BuildInfo .scalaVersion
529
+ ): Array [String ] =
530
+ Array [String ](
531
+ " -Yrangepos" ,
532
+ " -classpath" ,
533
+ s " ${scalaLibrary.mkString(" :" )}"
534
+ )
513
535
}
0 commit comments