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

Package / file exclusion does not work with Scala 3 #525

Closed
kyri-petrou opened this issue Dec 23, 2023 · 12 comments · Fixed by #541
Closed

Package / file exclusion does not work with Scala 3 #525

kyri-petrou opened this issue Dec 23, 2023 · 12 comments · Fixed by #541

Comments

@kyri-petrou
Copy link

Hi there. There seems that some coverage settings (primarily coverageExcludedPackages and coverageExcludedFiles, but I believe some other ones might be affected) are not working with Scala 3.

The easiest way to reproduce is by cloning the sbt-scoverage-samples repo, adding the following line to build.sbt:

coverageExcludedPackages := ".*"

and then running

sbt coverage +test +coverageReport

This yields the following:

Scala 2:

[success] Total time: 13 s, completed 23 Dec 2023, 12:55:46 pm
[info] Statement coverage.: 100.00%
[info] Branch coverage....: 100.00%
[info] Coverage reports completed

Scala 3:

[info] Statement coverage.: 65.20%
[info] Branch coverage....: 33.33%
[info] Coverage reports completed
@ckipp01
Copy link
Member

ckipp01 commented Dec 27, 2023

Hey @kyri-petrou, this is actually a limitation in the implementation of how coverage works with Scala 3. You can read more about it here. So it'd need to be added upstream in order for this to work.

@kyri-petrou
Copy link
Author

@ckipp01 aghh I see. Thanks!

@ivanobulo
Copy link

I created an MR to address the issue. It would benefit from the upstream changes, but it is not required. Coverage data can be filtered after it was collected.

@mcanlas
Copy link

mcanlas commented Apr 3, 2024

What is an "MR"?

@eschizoid
Copy link

eschizoid commented Apr 5, 2024

hey @ivanobulo I just tried release 3.4.2-RC1 and I am still unable to exclude packages or files using any of these options:

coverageExcludedPackages := ...
coverageExcludedFile     := ...

Wondering if I could be missing something else?

EDIT:
I was able to exclude files and packages passing the filter flags to the compiler options.

thank you so much for the fix 🙂

@alberto-spadoni3
Copy link

Could someone kindly explain me how can i exclude an entire package and all its subpackages from the scoverage report on Scala 3.4?
How can i exclude files and packages by passing the filter flags to the compiler options?

@eschizoid
Copy link

Could someone kindly explain me how can i exclude an entire package and all its subpackages from the scoverage report on Scala 3.4? How can i exclude files and packages by passing the filter flags to the compiler options?

https://docs.scala-lang.org/overviews/compiler-options/index.html

and i just added this flag:

"-coverage-exclude-files:packages_to_be_excluded"

@TonioGela
Copy link

@ckipp01 is upstream now fixed? Can we proceed implementing the fix that passes the proper flag to the compiler?

@jozic
Copy link
Contributor

jozic commented Jun 17, 2024

Scala 3 supports file and class/package exclusions since 3.4.2
scoverage-maven-plugin was updated recently to support Scala 3 compiler flags

scoverage/scoverage-maven-plugin#237

@ckipp01
Copy link
Member

ckipp01 commented Jun 17, 2024

@ckipp01 is upstream now fixed? Can we proceed implementing the fix that passes the proper flag to the compiler?

Yes, I believe this is fixed, but I also haven't been following. Please do submit a PR for it.

@TonioGela
Copy link

TonioGela commented Jun 17, 2024

Scala 3 supports file and class/package exclusions since 3.4.2 scoverage-maven-plugin was updated recently to support Scala 3 compiler flags

scoverage/scoverage-maven-plugin#237

@jozic can you work on a PR for sbt-scoverage too please :D ? I would do that but I assume you're more proficient with it given that you did it for maven :)

@jozic
Copy link
Contributor

jozic commented Jun 19, 2024

@TonioGela @ckipp01 #541

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants