diff --git a/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala b/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala index fa9bd3ea..609dcebc 100644 --- a/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala +++ b/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala @@ -18,15 +18,19 @@ class ScoveragePlugin(val global: Global) extends Plugin { val instrumentationComponent = new ScoverageInstrumentationComponent(global, extraAfterPhase, extraBeforePhase) override val components: List[PluginComponent] = List(instrumentationComponent) + private def parseExclusionEntry(entryName: String, inOption: String): Seq[String] = + inOption.substring(entryName.length).split(";").map(_.trim).toIndexedSeq.filterNot(_.isEmpty) + override def processOptions(opts: List[String], error: String => Unit): Unit = { val options = new ScoverageOptions + for (opt <- opts) { if (opt.startsWith("excludedPackages:")) { - options.excludedPackages = opt.substring("excludedPackages:".length).split(";").map(_.trim).filterNot(_.isEmpty) + options.excludedPackages = parseExclusionEntry("excludedPackages", opt) } else if (opt.startsWith("excludedFiles:")) { - options.excludedFiles = opt.substring("excludedFiles:".length).split(";").map(_.trim).filterNot(_.isEmpty) + options.excludedFiles = parseExclusionEntry("excludedFiles", opt) } else if (opt.startsWith("excludedSymbols:")) { - options.excludedSymbols = opt.substring("excludedSymbols:".length).split(";").map(_.trim).filterNot(_.isEmpty) + options.excludedSymbols = parseExclusionEntry("excludedSymbols", opt) } else if (opt.startsWith("dataDir:")) { options.dataDir = opt.substring("dataDir:".length) } else if (opt.startsWith("extraAfterPhase:") || opt.startsWith("extraBeforePhase:")) { diff --git a/scalac-scoverage-plugin/src/test/scala/scoverage/IOUtilsTest.scala b/scalac-scoverage-plugin/src/test/scala/scoverage/IOUtilsTest.scala index f653b835..d17a6c56 100644 --- a/scalac-scoverage-plugin/src/test/scala/scoverage/IOUtilsTest.scala +++ b/scalac-scoverage-plugin/src/test/scala/scoverage/IOUtilsTest.scala @@ -36,7 +36,7 @@ class IOUtilsTest extends FreeSpec with MockitoSugar with OneInstancePerTest wit writer2.close() val files = IOUtils.findMeasurementFiles(file1.getParent) - val invoked = IOUtils.invoked(files) + val invoked = IOUtils.invoked(files.toIndexedSeq) assert(invoked.toSet === Set(1, 2, 5, 7, 9, 10, 14)) file1.delete() diff --git a/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala b/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala index 20c9b895..2c292f61 100644 --- a/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala +++ b/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala @@ -263,9 +263,10 @@ class PluginCoverageTest | } | }""".stripMargin) assert(!compiler.reporter.hasErrors) - // 2 statements for the two applies in Seq, one for each literal which is 6, one for the flat map, - // one for the map, one for the yield op. - compiler.assertNMeasuredStatements(11) + // 2 statements for the two applies in Seq, one for each literal which is 6, one for the operation passed to yield. + // Depending on the collections api version, there can be additional implicit canBuildFrom statements. + val expectedStatementsCount = if (ScoverageCompiler.ShortScalaVersion < "2.13") 11 else 9 + compiler.assertNMeasuredStatements(expectedStatementsCount) } test("plugin should not instrument local macro implementation") { diff --git a/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala b/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala index 75abedbf..0a1b777c 100644 --- a/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala +++ b/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala @@ -102,8 +102,9 @@ class ScoverageCompiler(settings: scala.tools.nsc.Settings, reporter: scala.tool def assertNoCoverage() = assert(!testStore.sources.mkString(" ").contains(s"scoverage.Invoker.invoked")) + def assertNMeasuredStatements(n: Int): Unit = { - for ( k <- 1 to n ) { + for (k <- 1 to n) { assert(testStore.sources.mkString(" ").contains(s"scoverage.Invoker.invoked($k,"), s"Should be $n invoked statements but missing #$k") } @@ -139,7 +140,7 @@ class ScoverageCompiler(settings: scala.tools.nsc.Settings, reporter: scala.tool class Transformer(unit: global.CompilationUnit) extends TypingTransformer(unit) { override def transform(tree: global.Tree) = { - sources append tree.toString + sources += tree.toString tree } } diff --git a/scalac-scoverage-runtime/jvm/src/test/scala/scoverage/InvokerConcurrencyTest.scala b/scalac-scoverage-runtime/jvm/src/test/scala/scoverage/InvokerConcurrencyTest.scala index 7943db95..d9e7f6cb 100644 --- a/scalac-scoverage-runtime/jvm/src/test/scala/scoverage/InvokerConcurrencyTest.scala +++ b/scalac-scoverage-runtime/jvm/src/test/scala/scoverage/InvokerConcurrencyTest.scala @@ -5,7 +5,6 @@ import java.util.concurrent.Executors import org.scalatest.{BeforeAndAfter, FunSuite} -import scala.collection.breakOut import scala.concurrent._ import scala.concurrent.duration._ @@ -29,17 +28,17 @@ class InvokerConcurrencyTest extends FunSuite with BeforeAndAfter { // Create 1k "invoked" calls on the common thread pool, to stress test // the method - val futures: List[Future[Unit]] = testIds.map { i: Int => + val futures: Set[Future[Unit]] = testIds.map { i: Int => Future { Invoker.invoked(i, measurementDir.toString) } - }(breakOut) + } futures.foreach(Await.result(_, 1.second)) // Now verify that the measurement file is not corrupted by loading it val measurementFiles = Invoker.findMeasurementFiles(measurementDir) - val idsFromFile = Invoker.invoked(measurementFiles).toSet + val idsFromFile = Invoker.invoked(measurementFiles.toIndexedSeq).toSet idsFromFile === testIds } diff --git a/scalac-scoverage-runtime/shared/src/test/scala/scoverage/InvokerMultiModuleTest.scala b/scalac-scoverage-runtime/shared/src/test/scala/scoverage/InvokerMultiModuleTest.scala index 013153dd..2007c95d 100644 --- a/scalac-scoverage-runtime/shared/src/test/scala/scoverage/InvokerMultiModuleTest.scala +++ b/scalac-scoverage-runtime/shared/src/test/scala/scoverage/InvokerMultiModuleTest.scala @@ -27,12 +27,12 @@ class InvokerMultiModuleTest extends FunSuite with BeforeAndAfter { // Verify measurements went to correct directory val measurementFiles0 = Invoker.findMeasurementFiles(measurementDir(0)) - val idsFromFile0 = Invoker.invoked(measurementFiles0).toSet + val idsFromFile0 = Invoker.invoked(measurementFiles0.toIndexedSeq).toSet idsFromFile0 === testIds.filter { i: Int => i % 2 == 0 } val measurementFiles1 = Invoker.findMeasurementFiles(measurementDir(0)) - val idsFromFile1 = Invoker.invoked(measurementFiles1).toSet + val idsFromFile1 = Invoker.invoked(measurementFiles1.toIndexedSeq).toSet idsFromFile1 === testIds.filter { i: Int => i % 2 == 1 } }