-
Notifications
You must be signed in to change notification settings - Fork 45
Scala 3 support; Upgrade to Scoverage version 2.0.7 #188
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
Scala 3 support; Upgrade to Scoverage version 2.0.7 #188
Conversation
thanks very much - will review the test failures |
Thank you, @maiflai .
Where in the main branch the build looks as follows:
Any hint is much appreciated. |
I think this is because the scala version is now determined before the project is evaluated? |
You were right, this is exactly the issue. |
Lookup Scala version at the right time to avoid forcing early dependency resolution
Fix ScoverageFunctionalTest to use scalaVersionBuild=17 (2.12.17)
This version now builds fine: all tests go to success. |
Unit test for Scala 3 - picks up wrong Scala 2 compiler - push to ask for help
I added a Scala 3.2 case to the multi module cross version test suite.
I have not been able to figure out yet why Scala 2 compiler is used instead of Scala 3. @maiflai , all, do you have any suggestion? |
thanks again, will investigate |
I think that https://docs.gradle.org/current/userguide/scala_plugin.html suggests we need Gradle 7.5+ to compile Scala 3.x distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionSha256Sum=7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b Unfortunately several tests then fail - e.g.
I think it gets more complicated on your branch because scalatest has changed. testImplementation "org.scalatestplus:junit-4-13_3:3.2.14.0" // I did not see a JUnit 5 artefact import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.junit.JUnitRunner Even when this compiles, it fails to report coverage. Thoughts? |
Thanks a lot @maiflai for taking a look. I attached my test project: Scala3CodeCoverageViaGradle.zip It looks to me that Scoverage reporting works fine in this project: the report looks as expected, and also fails the build when coverage falls below the minimum rate.
This test project uses Gradle 7.4, I will try upgrade the Scoverage project to 7.4 as well. |
It compiles fine with Gradle 7.4, thanks again for the hint, @maiflai |
Let me give an update: I am struggling with the Scala 3 part of the scala-multi-module-cross-version test: In order to troubleshoot I copied the src/crossScalaVersionTest/resources/projects/scala-multi-module-cross-version into a separate Gradle project (named it GradleMultiFromScoveragePlugin). Then I triggered the same build from the Gradle Test Kit as follows: public class MainTest {
@Test
public void testHelloWorldTask() throws IOException {
final String mainTask = ":3_2:reportScoverage";
final File testProjectDir = new File("/home/marton/IdeaProjects/GradleMultiFromScoveragePlugin");
BuildResult result = GradleRunner.create()
.withProjectDir(testProjectDir)
.withArguments("clean", mainTask, "--info", "--full-stacktrace")
.build();
assertEquals(SUCCESS, result.task(mainTask).getOutcome());
}
} This build fails with the following error:
Interestingly different, and incorrect build/scoverage/scoverage.coverage file is generated in the Test Kit - the file path looks wrong:
I tried to play around with a few things such (i.e. working directory), but no luck yet. |
Upgrade to Gradle version 7.4, upgraded Scala 3 unit test libraries.
parameters.add("-P:scoverage:sourceRoot:${extension.project.getRootDir().absolutePath}".toString()) Perhaps the Test Kit moves the root directory to a temporary location? |
-sourceroot parameter must be added for Scala 3 to run the build in Gradle Test Kit.
Everything looks good, except 5 tests: these are the ones with the -PscoverageCompileOnly flag. |
gradle/gradle#20330 suggests that this might be an upstream issue. I'm working on a fork of this pull request; it seems that renaming the 'common' project to '_common' fixes the project resolution issues. |
Thank you @maiflai as always! |
This change is completed in #192 . |
Completed in #192 , closing. |
Added Scala 3 support, which also required to upgrade to the modularized Scoverage version 2.0.7.
I was able to test the plugin against Scala 2.13 as Scala 3 my publishing to the local Maven repository.
However the crossScalaVersionTests are failing, I am still working on that.
Please review, and let me know your feedback.