@@ -30,6 +30,12 @@ class ScalaCompilerForUnitTesting {
3030 tempSrcFiles.map(src => run.unitPhases(src.id))
3131 }
3232
33+ def extractTotal (srcs : String * )(extraSourcePath : String * ): Int = {
34+ val (tempSrcFiles, Callbacks (_, testProgress)) = compileSrcs(List (srcs.toList), extraSourcePath.toList)
35+ val run = testProgress.runs.head
36+ run.total
37+ }
38+
3339 def extractProgressPhases (srcs : String * ): List [String ] = {
3440 val (_, Callbacks (_, testProgress)) = compileSrcs(srcs : _* )
3541 testProgress.runs.head.phases
@@ -136,7 +142,7 @@ class ScalaCompilerForUnitTesting {
136142 * The sequence of temporary files corresponding to passed snippets and analysis
137143 * callback is returned as a result.
138144 */
139- def compileSrcs (groupedSrcs : List [List [String ]]): (Seq [VirtualFile ], Callbacks ) = {
145+ def compileSrcs (groupedSrcs : List [List [String ]], sourcePath : List [ String ] = Nil ): (Seq [VirtualFile ], Callbacks ) = {
140146 val temp = IO .createTemporaryDirectory
141147 val analysisCallback = new TestCallback
142148 val testProgress = new TestCompileProgress
@@ -146,6 +152,11 @@ class ScalaCompilerForUnitTesting {
146152 val bridge = new CompilerBridge
147153
148154 val files = for ((compilationUnits, unitId) <- groupedSrcs.zipWithIndex) yield {
155+ val extraFiles = sourcePath.toSeq.zipWithIndex.map {
156+ case (src, i) =>
157+ val fileName = s " Extra- $unitId- $i.scala "
158+ prepareSrcFile(temp, fileName, src)
159+ }
149160 val srcFiles = compilationUnits.toSeq.zipWithIndex.map {
150161 (src, i) =>
151162 val fileName = s " Test- $unitId- $i.scala "
@@ -157,10 +168,12 @@ class ScalaCompilerForUnitTesting {
157168 val output = new SingleOutput :
158169 def getOutputDirectory () = classesDir
159170
171+ val maybeSourcePath = if extraFiles.isEmpty then Nil else List (" -sourcepath" , temp.getAbsolutePath.toString)
172+
160173 bridge.run(
161174 virtualSrcFiles,
162175 new TestDependencyChanges ,
163- Array (" -Yforce-sbt-phases" , " -classpath" , classesDirPath, " -usejavacp" , " -d" , classesDirPath),
176+ Array (" -Yforce-sbt-phases" , " -classpath" , classesDirPath, " -usejavacp" , " -d" , classesDirPath) ++ maybeSourcePath ,
164177 output,
165178 analysisCallback,
166179 new TestReporter ,
0 commit comments