-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from tmandke/master
Add support for multi module project in runtime
- Loading branch information
Showing
2 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
scalac-scoverage-runtime/src/test/scala/scoverage/InvokerMultiModuleTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package scoverage | ||
|
||
import java.io.File | ||
|
||
import org.scalatest.{BeforeAndAfter, FunSuite} | ||
|
||
/** | ||
* Verify that [[Invoker.invoked()]] can handle a multi-module project | ||
*/ | ||
class InvokerMultiModuleTest extends FunSuite with BeforeAndAfter { | ||
|
||
val measurementDir = Array(new File("invoker-test.measurement0"), new File("invoker-test.measurement1")) | ||
|
||
before { | ||
deleteMeasurementFiles() | ||
measurementDir.foreach(_.mkdirs) | ||
} | ||
|
||
test("calling Invoker.invoked on with different directories puts mesurments in different directories") { | ||
|
||
val testIds: Set[Int] = (1 to 10).toSet | ||
|
||
testIds.map { i: Int => Invoker.invoked(i, measurementDir(i % 2).toString) } | ||
|
||
// Verify measurements went to correct directory | ||
val measurementFiles0 = Invoker.findMeasurementFiles(measurementDir(0)) | ||
val idsFromFile0 = Invoker.invoked(measurementFiles0).toSet | ||
|
||
idsFromFile0 === testIds.filter { i: Int => i % 2 == 0 } | ||
|
||
val measurementFiles1 = Invoker.findMeasurementFiles(measurementDir(0)) | ||
val idsFromFile1 = Invoker.invoked(measurementFiles1).toSet | ||
idsFromFile1 === testIds.filter { i: Int => i % 2 == 1 } | ||
} | ||
|
||
after { | ||
deleteMeasurementFiles() | ||
measurementDir.foreach(_.delete) | ||
} | ||
|
||
private def deleteMeasurementFiles(): Unit = { | ||
measurementDir.foreach((md) => { | ||
if (md.isDirectory) | ||
md.listFiles().foreach(_.delete()) | ||
}) | ||
} | ||
} |