Skip to content

Accept multiple phases instead of one #685

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 11 additions & 7 deletions plugin/src/main/scala/scoverage/ScoverageOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ object ScoverageOptions {
"-P:scoverage:excludedPackages:<regex>;<regex> semicolon separated list of regexs for packages to exclude",
"-P:scoverage:excludedFiles:<regex>;<regex> semicolon separated list of regexs for paths to exclude",
"-P:scoverage:excludedSymbols:<regex>;<regex> semicolon separated list of regexs for symbols to exclude",
"-P:scoverage:extraAfterPhase:<phaseName> phase after which scoverage phase runs (must be after typer phase)",
"-P:scoverage:extraBeforePhase:<phaseName> phase before which scoverage phase runs (must be before patmat phase)",
"-P:scoverage:extraAfterPhase:<phaseName>;<phaseName> phase after which scoverage phase runs (must be after typer phase)",
"-P:scoverage:extraBeforePhase:<phaseName>;<phaseName> phase before which scoverage phase runs (must be before patmat phase)",
" Any classes whose fully qualified name matches the regex will",
" be excluded from coverage."
).mkString("\n")
Expand Down Expand Up @@ -72,12 +72,16 @@ object ScoverageOptions {

def processPhaseOptions(
opts: List[String]
): (Option[String], Option[String]) = {
): (Option[List[String]], Option[List[String]]) = {

val afterPhase: Option[String] =
opts.collectFirst { case ExtraAfterPhase(phase) => phase }
val beforePhase: Option[String] =
opts.collectFirst { case ExtraBeforePhase(phase) => phase }
val afterPhase: Option[List[String]] =
opts.collectFirst { case ExtraAfterPhase(phase) =>
phase.split(";").toList
}
val beforePhase: Option[List[String]] =
opts.collectFirst { case ExtraBeforePhase(phase) =>
phase.split(";").toList
}

(afterPhase, beforePhase)
}
Expand Down
8 changes: 4 additions & 4 deletions plugin/src/main/scala/scoverage/ScoveragePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ class ScoveragePlugin(val global: Global) extends Plugin {

class ScoverageInstrumentationComponent(
val global: Global,
extraAfterPhase: Option[String],
extraBeforePhase: Option[String]
extraAfterPhase: Option[List[String]],
extraBeforePhase: Option[List[String]]
) extends PluginComponent
with TypingTransformers
with Transform {
Expand All @@ -87,9 +87,9 @@ class ScoverageInstrumentationComponent(

override val phaseName: String = ScoveragePlugin.phaseName
override val runsAfter: List[String] =
List("typer") ::: extraAfterPhase.toList
List("typer") ::: extraAfterPhase.getOrElse(Nil)
override val runsBefore: List[String] =
List("patmat") ::: extraBeforePhase.toList
List("patmat") ::: extraBeforePhase.getOrElse(Nil)

/** Our options are not provided at construction time, but shortly after,
* so they start as None.
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/test/scala/scoverage/ScoverageOptionsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class ScoverageOptionsTest extends FunSuite {
"excludedPackages:some.package;another.package*",
"excludedFiles:*.proto;iHateThisFile.scala",
"excludedSymbols:someSymbol;anotherSymbol;aThirdSymbol",
"extraAfterPhase:extarAfter",
"extraBeforePhase:extraBefore",
"extraAfterPhase:extarAfter;extraAfter2",
"extraBeforePhase:extraBefore;extraBefore2",
"reportTestName"
)

Expand Down