@@ -30,6 +30,12 @@ class ScalaCompilerForUnitTesting {
30
30
tempSrcFiles.map(src => run.unitPhases(src.id))
31
31
}
32
32
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
+
33
39
def extractProgressPhases (srcs : String * ): List [String ] = {
34
40
val (_, Callbacks (_, testProgress)) = compileSrcs(srcs : _* )
35
41
testProgress.runs.head.phases
@@ -136,7 +142,7 @@ class ScalaCompilerForUnitTesting {
136
142
* The sequence of temporary files corresponding to passed snippets and analysis
137
143
* callback is returned as a result.
138
144
*/
139
- def compileSrcs (groupedSrcs : List [List [String ]]): (Seq [VirtualFile ], Callbacks ) = {
145
+ def compileSrcs (groupedSrcs : List [List [String ]], sourcePath : List [ String ] = Nil ): (Seq [VirtualFile ], Callbacks ) = {
140
146
val temp = IO .createTemporaryDirectory
141
147
val analysisCallback = new TestCallback
142
148
val testProgress = new TestCompileProgress
@@ -146,6 +152,11 @@ class ScalaCompilerForUnitTesting {
146
152
val bridge = new CompilerBridge
147
153
148
154
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
+ }
149
160
val srcFiles = compilationUnits.toSeq.zipWithIndex.map {
150
161
(src, i) =>
151
162
val fileName = s " Test- $unitId- $i.scala "
@@ -157,10 +168,12 @@ class ScalaCompilerForUnitTesting {
157
168
val output = new SingleOutput :
158
169
def getOutputDirectory () = classesDir
159
170
171
+ val maybeSourcePath = if extraFiles.isEmpty then Nil else List (" -sourcepath" , temp.getAbsolutePath.toString)
172
+
160
173
bridge.run(
161
174
virtualSrcFiles,
162
175
new TestDependencyChanges ,
163
- Array (" -Yforce-sbt-phases" , " -classpath" , classesDirPath, " -usejavacp" , " -d" , classesDirPath),
176
+ Array (" -Yforce-sbt-phases" , " -classpath" , classesDirPath, " -usejavacp" , " -d" , classesDirPath) ++ maybeSourcePath ,
164
177
output,
165
178
analysisCallback,
166
179
new TestReporter ,
0 commit comments