Skip to content

Commit 7d1efcf

Browse files
fix: Accept multiple phases instead of one
- #164 opened up the possibility of configurable phase control - But sometimes, one may need to use more phases than one - Now accepts multiple phases delimited by ; - This is for making it consistent along other options
1 parent e2e59ed commit 7d1efcf

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

plugin/src/main/scala/scoverage/ScoverageOptions.scala

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ object ScoverageOptions {
2727
"-P:scoverage:excludedPackages:<regex>;<regex> semicolon separated list of regexs for packages to exclude",
2828
"-P:scoverage:excludedFiles:<regex>;<regex> semicolon separated list of regexs for paths to exclude",
2929
"-P:scoverage:excludedSymbols:<regex>;<regex> semicolon separated list of regexs for symbols to exclude",
30-
"-P:scoverage:extraAfterPhase:<phaseName> phase after which scoverage phase runs (must be after typer phase)",
31-
"-P:scoverage:extraBeforePhase:<phaseName> phase before which scoverage phase runs (must be before patmat phase)",
30+
"-P:scoverage:extraAfterPhase:<phaseName>;<phaseName> phase after which scoverage phase runs (must be after typer phase)",
31+
"-P:scoverage:extraBeforePhase:<phaseName>;<phaseName> phase before which scoverage phase runs (must be before patmat phase)",
3232
" Any classes whose fully qualified name matches the regex will",
3333
" be excluded from coverage."
3434
).mkString("\n")
@@ -72,12 +72,16 @@ object ScoverageOptions {
7272

7373
def processPhaseOptions(
7474
opts: List[String]
75-
): (Option[String], Option[String]) = {
75+
): (Option[List[String]], Option[List[String]]) = {
7676

77-
val afterPhase: Option[String] =
78-
opts.collectFirst { case ExtraAfterPhase(phase) => phase }
79-
val beforePhase: Option[String] =
80-
opts.collectFirst { case ExtraBeforePhase(phase) => phase }
77+
val afterPhase: Option[List[String]] =
78+
opts.collectFirst { case ExtraAfterPhase(phase) =>
79+
phase.split(";").toList
80+
}
81+
val beforePhase: Option[List[String]] =
82+
opts.collectFirst { case ExtraBeforePhase(phase) =>
83+
phase.split(";").toList
84+
}
8185

8286
(afterPhase, beforePhase)
8387
}

plugin/src/main/scala/scoverage/ScoveragePlugin.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class ScoveragePlugin(val global: Global) extends Plugin {
7474

7575
class ScoverageInstrumentationComponent(
7676
val global: Global,
77-
extraAfterPhase: Option[String],
78-
extraBeforePhase: Option[String]
77+
extraAfterPhase: Option[List[String]],
78+
extraBeforePhase: Option[List[String]]
7979
) extends PluginComponent
8080
with TypingTransformers
8181
with Transform {
@@ -87,9 +87,9 @@ class ScoverageInstrumentationComponent(
8787

8888
override val phaseName: String = ScoveragePlugin.phaseName
8989
override val runsAfter: List[String] =
90-
List("typer") ::: extraAfterPhase.toList
90+
List("typer") ::: extraAfterPhase.getOrElse(Nil)
9191
override val runsBefore: List[String] =
92-
List("patmat") ::: extraBeforePhase.toList
92+
List("patmat") ::: extraBeforePhase.getOrElse(Nil)
9393

9494
/** Our options are not provided at construction time, but shortly after,
9595
* so they start as None.

plugin/src/test/scala/scoverage/ScoverageOptionsTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class ScoverageOptionsTest extends FunSuite {
1111
"excludedPackages:some.package;another.package*",
1212
"excludedFiles:*.proto;iHateThisFile.scala",
1313
"excludedSymbols:someSymbol;anotherSymbol;aThirdSymbol",
14-
"extraAfterPhase:extarAfter",
15-
"extraBeforePhase:extraBefore",
14+
"extraAfterPhase:extarAfter;extraAfter2",
15+
"extraBeforePhase:extraBefore;extraBefore2",
1616
"reportTestName"
1717
)
1818

0 commit comments

Comments
 (0)