Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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 code exclusion from coverage instrumentation #17684

Closed
jozic opened this issue Oct 13, 2022 · 1 comment
Closed

Support code exclusion from coverage instrumentation #17684

jozic opened this issue Oct 13, 2022 · 1 comment

Comments

@jozic
Copy link

jozic commented Oct 13, 2022

Original scalac scoverage plugin supports excluding code from instrumentation and reports
https://github.com/scoverage/scalac-scoverage-plugin#excluding-code-from-coverage-stats
Scala 3 can support it as well, to make transition from Scala 2 easier.

Also, any hints for volunteers on where to start are highly appreciated :)
Thank you!

@TheElectronWill
Copy link
Member

TheElectronWill commented Oct 24, 2022

Okay, here's some hint :)
Coverage instrumentation is done by the phase instrumentCoverage in compiler/src/dotty/tools/dotc/transform/InstrumentCoverage.scala.

The most performant form of exclusion is to exclude files. The current "compilation unit" provides the source that is being compiled:

ctx.compilationUnit.source

This could be used to disable the instrumentation phase according to a collection of regex-like strings. We have -coverage-out to configure the output of scoverage files, we could have -coverage-exclude-files or something like that. Such options are defined in ScalaSettings, you can see how -coverage-out has been defined.

Excluding packages (or worse, classes) looks a bit more complicated.

@ckipp01 ckipp01 transferred this issue from lampepfl/dotty-feature-requests May 31, 2023
@scala scala locked and limited conversation to collaborators May 31, 2023
@ckipp01 ckipp01 converted this issue into discussion #17685 May 31, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants