-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
better test infrastructure for Scala 3 #1528
Conversation
2c370fd
to
b235d4e
Compare
buildScalaVersions.map(VirtualAxis.scalaABIVersion) :+ VirtualAxis.jvm: _* | ||
) | ||
.customRow( | ||
scalaVersions = Seq(scala212), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not 2.13? Because 2.12 is still the default in sbt-scalafix
crossPublishLocalBinTransitive := { | ||
val currentState = state.value | ||
val ref = thisProjectRef.value | ||
val versions = crossScalaVersions.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/sbt/sbt-projectmatrix/blob/e46c2e3c3a4eba186a204303834e5d01893455b7/src/main/scala/sbt/internal/ProjectMatrix.scala#L145 has exactly what we need to iterate over versions so we can get rid of this (which would have required some tweaks anyway since crossScalaVersions
is not set anymore). Note that we do lose the optimization of not generating/publishing docs & src, but the removal in complexity is worth it IMHO.
2367055
to
4d1b2fe
Compare
@@ -5,3 +5,4 @@ addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "2.0.1") | |||
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.3.2") | |||
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") | |||
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34") | |||
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see scalacenter/scalafix.g8#19 for some prior discussions
b307242
to
1d42d5d
Compare
620d6f1
to
b375137
Compare
@@ -93,7 +93,6 @@ object Test { | |||
val annType1: T @ann(42) = ??? | |||
val annType2: T @ann1 @ann2 = ??? | |||
|
|||
val existentialType1: T forSome { type T } = ??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existential types are longer supported in Scala 3 and rarely used in Scala 2 so for the sake of simplicity, I dropped this completely.
@@ -63,7 +63,7 @@ | |||
[59:9..59:10]: test/Test.M#m(). => method m: Int | |||
[62:9..62:10]: test/Test.N# => trait N extends AnyRef { +1 decls } | |||
[63:9..63:10]: test/Test.N#n(). => method n: Int | |||
[66:9..66:10]: test/Test.C# => class C extends M { +36 decls } | |||
[66:9..66:10]: test/Test.C# => class C extends M { +35 decls } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sbt save-expect
// The symbol lookup fails against Scala 3.1.1 SemanticDB as the position | ||
// there excludes surrounding parentheses while 2.x (scalac-semanticdb) and | ||
// the parser include them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not familiar with changes in Scala 3, but I know there has been changes to the infix behavior. Where should we report this mismatch between scalameta's parser and dotty's semanticdb output? Is it something that should be addressed in Dotty, in scalameta, or here?
Opening a ticket for tracking as it's a bug that this PR exposes #1594
sourceDir / s"scala-target$n", | ||
sourceDir / s"scala-target$n.$m" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this allows to restrict execution of certain tests based on what the unit combination is testing against
8ed62a7
to
ae82a10
Compare
[sbt-projectmatrix](https://github.com/sbt/sbt-projectmatrix) is used to | ||
generate several sbt projects `unitXTargetY` with the same source code, | ||
but for a combination of Scala versions: | ||
- used for compiling the framework and rules (`X`) | ||
- used for compiling and generating SemanticDB files for the test input (`Y`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not ideal given the tests currently located in unit
: most of them are NOT related to the target, so we end up running twice these "truely unit" tests (unit2_12Target2_12
& unit2_12Target3
).
// The defaults of this helper expect to find test input which is currently | ||
// built only on scala 2.x since building them for Scala 3 would trigger | ||
// test failures as the rules they exercise are not supported on Scala 3. | ||
// TODO: switch defaults to rely on much more simple test input/rules so | ||
// that we don't need to hardcode a scala version here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only one user of this helper is actively relying on defaults and fails on Scala 3 targets, but I moved all of them for consistency
@@ -0,0 +1,44 @@ | |||
package scalafix.tests.cli |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These rules extracted from CliSyntacticSuite were referenced in
scalafix/scalafix-tests/unit/src/main/resources/META-INF/services/scalafix.v1.Rule
Lines 8 to 13 in 660877e
scalafix.tests.cli.CrashingRule | |
scalafix.tests.cli.NoOpRule | |
scalafix.tests.cli.DeprecatedName | |
scalafix.tests.cli.Scala2_9 | |
scalafix.tests.cli.AvailableRule | |
scalafix.tests.cli.Disable |
test/scala-2
s"++$scala213" :: | ||
"cli/crossPublishLocalBinTransitive" :: // scalafix.tests.interfaces.ScalafixSuite | ||
s"unit/testOnly -- -l scalafix.internal.tests.utils.SkipWindows" :: | ||
"publishLocalTransitive" :: // scalafix.tests.interfaces.ScalafixSuite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
publishLocalTransitive
is only defined in cli*
projects so running this at the root triggers them through aggregation
// As of scalameta 4.5.3, this relies on scalap (and not on TASTy), so it | ||
// cannot work against classes compiled with Scala 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,50 @@ | |||
import sbt._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goals: - make it easier to understand we use 2.12 to run/test against 3 - allow more parallel building/testing
s"""set testsInput/scalaVersion := "$scala3"""" :: | ||
s"""set testsOutput/scalaVersion := "$scala3"""" :: | ||
"unit/testOnly scalafix.tests.rule.RuleSuite" :: s | ||
"unit2_12Target3/test" :: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or unit_213Target3
: Both should work no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unit2_13Target3
does not exist for the moment, see #1528 (comment). We could add it though, but I am not sure it brings a lot of value until/unless scalafixScalaBinaryVersion
is updated.
@@ -3,6 +3,7 @@ package scalafix.tests.v0 | |||
import scala.meta._ | |||
import scalafix.tests.core.BaseSemanticSuite | |||
|
|||
// LegacySyntheticsTest cannot be compiled with Scala 2.13 or Scala 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One day we would need to clean these old interfaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely. I had a quick look at it, but I am not familiar enough with the API to know what is still relevant, so I decided to limit the number of changes...
Thanks a lot for making #1583 easier to test! |
Unlocks #1480
Should make testing #1583 easier
Exposed one bug #1594
See commit messages