Skip to content

Commit f6a9557

Browse files
mlachkarbjaglin
authored andcommitted
ignore failing tests for scala 3
1 parent 4c354fd commit f6a9557

File tree

5 files changed

+44
-13
lines changed

5 files changed

+44
-13
lines changed

build.sbt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,6 @@ lazy val unit = projectMatrix
224224
Test / baseDirectory := (ThisBuild / baseDirectory).value,
225225
javaOptions := Nil,
226226
testFrameworks += new TestFramework("munit.Framework"),
227-
buildInfoPackage := "scalafix.tests",
228-
buildInfoObject := "BuildInfo",
229227
libraryDependencies += jgit,
230228
libraryDependencies ++= {
231229
if (!isScala3.value) {
@@ -303,8 +301,11 @@ lazy val unit = projectMatrix
303301
IO.write(props, "Input data for scalafix testkit", out)
304302
List(out)
305303
},
304+
buildInfoPackage := "scalafix.tests",
305+
buildInfoObject := "BuildInfo",
306306
buildInfoKeys := Seq[BuildInfoKey](
307307
"scalametaVersion" -> scalametaV,
308+
"scalaVersion" -> scalaVersion.value,
308309
"baseDirectory" ->
309310
(ThisBuild / baseDirectory).value,
310311
"unitResourceDirectory" -> (Compile / resourceDirectory).value,

scalafix-tests/unit/src/test/scala-2/scalafix/tests/util/compat/CompatSemanticdb.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package scalafix.tests.util.compat
33
import java.nio.file.Path
44

55
import scala.tools.nsc.Main
6+
67
object CompatSemanticdb {
78

89
def scalacOptions(src: Path, target: Path): Array[String] = {

scalafix-tests/unit/src/test/scala/scalafix/tests/cli/ScalafixImplSuite.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ class ScalafixImplSuite extends AnyFunSuite with DiffAssertions {
135135
}
136136

137137
test("runMain") {
138+
// Todo(i1680): this is an integration test that uses many non supported rules in scala 3.
139+
// Add a more simple test for scala 3. For now we ignore for Scala 3.
140+
if (ScalaVersions.isScala3) cancel()
138141
// This is a full integration test that stresses the full breadth of the scalafix-interfaces API
139142
val api = i.Scalafix.classloadInstance(this.getClass.getClassLoader)
140143
// Assert that non-ascii characters read into "?"

scalafix-tests/unit/src/test/scala/scalafix/tests/interfaces/ScalafixArgumentsSuite.scala

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import scala.util.Try
1313
import scala.meta.internal.io.FileIO
1414
import scala.meta.io.AbsolutePath
1515

16-
import buildinfo.RulesBuildInfo
1716
import org.scalatest.funsuite.AnyFunSuite
1817
import scalafix.interfaces.ScalafixArguments
1918
import scalafix.interfaces.ScalafixDiagnostic
@@ -26,16 +25,15 @@ import scalafix.internal.rule.RemoveUnusedConfig
2625
import scalafix.internal.tests.utils.SkipWindows
2726
import scalafix.test.StringFS
2827
import scalafix.testkit.DiffAssertions
28+
import scalafix.tests.BuildInfo
2929
import scalafix.tests.core.Classpaths
3030
import scalafix.tests.util.ScalaVersions
3131
import scalafix.tests.util.compat.CompatSemanticdb
3232
import scalafix.v1.SemanticRule
3333

3434
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 =
3937
if (ScalaVersions.isScala213)
4038
"-Wunused:imports"
4139
else "-Ywarn-unused-import"
@@ -66,16 +64,24 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
6664
val main: Path = src.resolve("Main.scala")
6765
val relativePath: Path = cwd.relativize(main)
6866

67+
val specificScalacOption2: Seq[String] =
68+
if (!ScalaVersions.isScala3)
69+
Seq(removeUnused)
70+
else Nil
71+
6972
val scalacOptions: Array[String] = Array[String](
70-
removeUnused,
7173
"-classpath",
7274
s"${scalaLibrary.mkString(":")}",
7375
"-d",
7476
d.toString,
7577
main.toString
76-
) ++ CompatSemanticdb.scalacOptions(src, target)
78+
) ++ specificScalacOption2 ++ CompatSemanticdb.scalacOptions(src, target)
7779

7880
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+
7985
val _ = CompatSemanticdb.runScalac(scalacOptions)
8086
val result = api
8187
.withRules(
@@ -155,6 +161,8 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
155161
}
156162

157163
test("ScalafixArguments.evaluate getting StaleSemanticdb", SkipWindows) {
164+
// Todo(i1680): We need a semanticRule in scala 3.
165+
if (ScalaVersions.isScala3) cancel()
158166
val _ = CompatSemanticdb.runScalac(scalacOptions)
159167
val args = api
160168
.withRules(
@@ -188,6 +196,8 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
188196
"ScalafixArguments.evaluate doesn't take into account withMode and withMainCallback",
189197
SkipWindows
190198
) {
199+
// Todo(i1680): We need a semanticRule in scala 3.
200+
if (ScalaVersions.isScala3) cancel()
191201
val _ = CompatSemanticdb.runScalac(scalacOptions)
192202
val contentBeforeEvaluation =
193203
FileIO.slurp(AbsolutePath(main), StandardCharsets.UTF_8)
@@ -341,6 +351,8 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
341351
}
342352

343353
test("Scalafix-evaluation-error-messages: missing semanticdb", SkipWindows) {
354+
// Todo(i1680): We need a semanticRule in scala 3.
355+
if (ScalaVersions.isScala3) cancel()
344356
val eval = api
345357
.withPaths(Seq(main).asJava)
346358
.withRules(List("ExplicitResultTypes").asJava)
@@ -433,7 +445,9 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
433445
test("Scala 3 style wildcard import", SkipWindows) {
434446
// https://github.com/scalacenter/scalafix/issues/1663
435447

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) {
437451
cancel()
438452
}
439453

@@ -510,4 +524,12 @@ class ScalafixArgumentsSuite extends AnyFunSuite with DiffAssertions {
510524

511525
def scalaLibrary: Seq[AbsolutePath] = Classpaths.scalaLibrary.entries
512526

527+
def scalacOptions(
528+
scalaVersion: String = BuildInfo.scalaVersion
529+
): Array[String] =
530+
Array[String](
531+
"-Yrangepos",
532+
"-classpath",
533+
s"${scalaLibrary.mkString(":")}"
534+
)
513535
}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package scalafix.tests.util
22

3+
import scalafix.tests.BuildInfo
4+
35
object ScalaVersions {
46
def isScala211: Boolean =
5-
util.Properties.versionNumberString.startsWith("2.11")
7+
BuildInfo.scalaVersion.startsWith("2.11")
68
def isScala212: Boolean =
7-
util.Properties.versionNumberString.startsWith("2.12")
9+
BuildInfo.scalaVersion.startsWith("2.12")
810
def isScala213: Boolean =
9-
util.Properties.versionNumberString.startsWith("2.13")
11+
BuildInfo.scalaVersion.startsWith("2.13")
12+
def isScala3: Boolean =
13+
BuildInfo.scalaVersion.startsWith("3")
1014
}

0 commit comments

Comments
 (0)