Skip to content
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

Properly handle multiple exclude entries for Scala 3 #548

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/scala/scoverage/ScoverageSbtPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ object ScoverageSbtPlugin extends AutoPlugin {
if isScala3SupportingFilePackageExclusion(
scalaVersion.value
) =>
s"-coverage-exclude-classlikes:$v"
s"-coverage-exclude-classlikes:${v.replace(';', ',')}"
},
excludedFiles
.collect {
case v
if isScala3SupportingFilePackageExclusion(
scalaVersion.value
) =>
s"-coverage-exclude-files:$v"
s"-coverage-exclude-files:${v.replace(';', ',')}"
}
).flatten
} else if (coverageEnabled.value && !isScala2(scalaVersion.value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ scalaVersion := "3.4.2"

libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test

coverageExcludedFiles := ".*/two/GoodCoverage"
coverageExcludedFiles := ".*/two/GoodCoverage;.*/three/GoodCoverage"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the forward slashes need to be escaped like this ... ???

coverageExcludedFiles := ".*\\/two\\/GoodCoverage;.*\\/three\\/.*"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, not sure about slashes. I believe it works as is on Linux which is proven by tests. But maybe you would want to add a windows environment for the checks and we can see if tests pass.

And thanks for checking the PR!


resolvers ++= {
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package three

object GoodCoverage {

def sum(num1: Int, num2: Int) = {
if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ scalaVersion := "3.4.2"

libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test

coverageExcludedPackages := "two\\..*"
coverageExcludedPackages := "two\\..*;three\\..*"

resolvers ++= {
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package three

object GoodCoverage {

def sum(num1: Int, num2: Int) = {
if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2
}

}