-
-
Notifications
You must be signed in to change notification settings - Fork 370
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
Support Scoverage for Scala 3 #2016
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
contrib/scoverage/test/resources/hello-world/core/test/src/GreetSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package mill.contrib.scoverage | |
import mill._ | ||
import mill.contrib.buildinfo.BuildInfo | ||
import mill.scalalib.{DepSyntax, ScalaModule, TestModule} | ||
import mill.scalalib.api.ZincWorkerUtil | ||
import mill.util.{TestEvaluator, TestUtil} | ||
import utest._ | ||
import utest.framework.TestPath | ||
|
@@ -96,8 +97,13 @@ trait HelloWorldTests extends utest.TestSuite { | |
val Right((result, evalCount)) = | ||
eval.apply(HelloWorld.core.scoverage.ivyDeps) | ||
|
||
val expected = if (ZincWorkerUtil.isScala3(testScalaVersion)) Agg.empty | ||
else Agg( | ||
ivy"org.scoverage::scalac-scoverage-runtime:${testScoverageVersion}" | ||
) | ||
|
||
assert( | ||
result == Agg(ivy"org.scoverage::scalac-scoverage-runtime:${testScoverageVersion}"), | ||
result == expected, | ||
evalCount > 0 | ||
) | ||
} | ||
|
@@ -117,14 +123,19 @@ trait HelloWorldTests extends utest.TestSuite { | |
"scoverage2x" - workspaceTest(HelloWorld) { eval => | ||
val Right((result, evalCount)) = | ||
eval.apply(HelloWorld.core.scoverage.scalacPluginIvyDeps) | ||
|
||
val expected = if (ZincWorkerUtil.isScala3(testScalaVersion)) Agg.empty | ||
else | ||
Agg( | ||
ivy"org.scoverage:::scalac-scoverage-plugin:${testScoverageVersion}", | ||
ivy"org.scoverage::scalac-scoverage-domain:${testScoverageVersion}", | ||
ivy"org.scoverage::scalac-scoverage-serializer:${testScoverageVersion}", | ||
ivy"org.scoverage::scalac-scoverage-reporter:${testScoverageVersion}" | ||
) | ||
|
||
if (testScoverageVersion.startsWith("2.")) { | ||
assert( | ||
result == Agg( | ||
ivy"org.scoverage:::scalac-scoverage-plugin:${testScoverageVersion}", | ||
ivy"org.scoverage::scalac-scoverage-domain:${testScoverageVersion}", | ||
ivy"org.scoverage::scalac-scoverage-serializer:${testScoverageVersion}", | ||
ivy"org.scoverage::scalac-scoverage-reporter:${testScoverageVersion}" | ||
), | ||
result == expected, | ||
evalCount > 0 | ||
) | ||
} else "skipped" | ||
|
@@ -161,27 +172,55 @@ trait HelloWorldTests extends utest.TestSuite { | |
val Right((result, evalCount)) = | ||
eval.apply(HelloWorld.core.scoverage.upstreamAssemblyClasspath) | ||
|
||
assert( | ||
result.map(_.toString).iterator.exists(_.contains("scalac-scoverage-runtime")), | ||
evalCount > 0 | ||
) | ||
val runtimeExistsOnClasspath = | ||
result.map(_.toString).iterator.exists(_.contains("scalac-scoverage-runtime")) | ||
if (ZincWorkerUtil.isScala3(testScalaVersion)) { | ||
assert( | ||
!runtimeExistsOnClasspath, | ||
evalCount > 0 | ||
) | ||
} else { | ||
assert( | ||
runtimeExistsOnClasspath, | ||
evalCount > 0 | ||
) | ||
} | ||
} | ||
"compileClasspath" - workspaceTest(HelloWorld) { eval => | ||
val Right((result, evalCount)) = eval.apply(HelloWorld.core.scoverage.compileClasspath) | ||
|
||
assert( | ||
result.map(_.toString).iterator.exists(_.contains("scalac-scoverage-runtime")), | ||
evalCount > 0 | ||
) | ||
val runtimeExistsOnClasspath = | ||
result.map(_.toString).iterator.exists(_.contains("scalac-scoverage-runtime")) | ||
if (ZincWorkerUtil.isScala3(testScalaVersion)) { | ||
assert( | ||
!runtimeExistsOnClasspath, | ||
evalCount > 0 | ||
) | ||
} else { | ||
assert( | ||
runtimeExistsOnClasspath, | ||
evalCount > 0 | ||
) | ||
} | ||
} | ||
// TODO: document why we disable for Java9+ | ||
"runClasspath" - workspaceTest(HelloWorld) { eval => | ||
val Right((result, evalCount)) = eval.apply(HelloWorld.core.scoverage.runClasspath) | ||
|
||
assert( | ||
result.map(_.toString).exists(_.contains("scalac-scoverage-runtime")), | ||
evalCount > 0 | ||
) | ||
val runtimeExistsOnClasspath = | ||
result.map(_.toString).iterator.exists(_.contains("scalac-scoverage-runtime")) | ||
|
||
if (ZincWorkerUtil.isScala3(testScalaVersion)) { | ||
assert( | ||
!runtimeExistsOnClasspath, | ||
evalCount > 0 | ||
) | ||
} else { | ||
assert( | ||
runtimeExistsOnClasspath, | ||
evalCount > 0 | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -212,19 +251,26 @@ object HelloWorldTests_2_12 extends HelloWorldTests { | |
override def threadCount = Some(1) | ||
override def testScalaVersion: String = sys.props.getOrElse("MILL_SCALA_2_12_VERSION", ???) | ||
override def testScoverageVersion = sys.props.getOrElse("MILL_SCOVERAGE_VERSION", ???) | ||
override def testScalatestVersion = "3.0.8" | ||
override def testScalatestVersion = "3.2.13" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ended up having to bump all these because 3.0.8 doesn't support Scala 3. |
||
} | ||
|
||
object HelloWorldTests_2_13 extends HelloWorldTests { | ||
override def threadCount = Some(1) | ||
override def testScalaVersion: String = sys.props.getOrElse("TEST_SCALA_2_13_VERSION", ???) | ||
override def testScoverageVersion = sys.props.getOrElse("MILL_SCOVERAGE_VERSION", ???) | ||
override def testScalatestVersion = "3.0.8" | ||
override def testScalatestVersion = "3.2.13" | ||
} | ||
|
||
object Scoverage2Tests_2_13 extends HelloWorldTests { | ||
override def threadCount = Some(1) | ||
override def testScalaVersion: String = sys.props.getOrElse("TEST_SCALA_2_13_VERSION", ???) | ||
override def testScoverageVersion = sys.props.getOrElse("MILL_SCOVERAGE2_VERSION", ???) | ||
override def testScalatestVersion = "3.0.8" | ||
override def testScalatestVersion = "3.2.13" | ||
} | ||
|
||
object Scoverage2Tests_3 extends HelloWorldTests { | ||
override def threadCount = Some(1) | ||
override def testScalaVersion: String = "3.2.0" | ||
override def testScoverageVersion = sys.props.getOrElse("MILL_SCOVERAGE2_VERSION", ???) | ||
override def testScalatestVersion = "3.2.13" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thing I'm having a hard time with is figuring out where to put this check. At first I thought it'd be better to put it up above and in every task that computes something I could use like
So then I could just do like:
But that fell apart when I hit
scoveragteToolsClasspath
and couldn't get it to work.Then I moved this down below into
ScoverageData
and I thought about adding anassert
in here to check for an invalid Scala 3, but can't really access the scalaVersion in the assert. I'm not really sure where to do this check. Any input on where you'd think this would be best and how to do it?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.
Moreover this should also check that if this is a valid Scala 3 version then the user must also be using scoverage 2.x. It'd be nice to do this check in one place.
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 think this check is best placed in
scoverageToolsClasspath
. It has access to all required data and is run before any worker action. Also, as there can be no valid classpath created in case we have an incompatible Scala version or an inappropriate scoverage version, this is the best place for this validation.