@@ -82,7 +82,7 @@ abstract class CompilerTest extends DottyTest {
82
82
* @param extension the file extension, .scala by default
83
83
* @param defaultOptions more arguments to the compiler
84
84
*/
85
- def compileFile (prefix : String , fileName : String , args : List [String ] = Nil , xerrors : Int = 0 ,
85
+ def compileFile (prefix : String , fileName : String , args : List [String ] = Nil , xerrors : Int = 0 ,
86
86
extension : String = " .scala" , runTest : Boolean = false )
87
87
(implicit defaultOptions : List [String ]): Unit = {
88
88
if (! generatePartestFiles || ! partestableFile(prefix, fileName, extension, args ++ defaultOptions, xerrors)) {
@@ -102,7 +102,8 @@ abstract class CompilerTest extends DottyTest {
102
102
}
103
103
}
104
104
}
105
- def runFile (prefix : String , fileName : String , args : List [String ] = Nil , xerrors : Int = 0 ,
105
+
106
+ def runFile (prefix : String , fileName : String , args : List [String ] = Nil , xerrors : Int = 0 ,
106
107
extension : String = " .scala" )(implicit defaultOptions : List [String ]): Unit =
107
108
compileFile(prefix, fileName, args, xerrors, extension, true )
108
109
@@ -140,23 +141,28 @@ abstract class CompilerTest extends DottyTest {
140
141
}
141
142
}
142
143
}
144
+
143
145
def runDir (prefix : String , dirName : String , args : List [String ] = Nil , xerrors : Int = 0 )
144
146
(implicit defaultOptions : List [String ]): Unit =
145
147
compileDir(prefix, dirName, args, xerrors, true )
146
148
149
+ def runFiles (path : String , args : List [String ] = Nil , verbose : Boolean = true )
150
+ (implicit defaultOptions : List [String ]): Unit =
151
+ compileFiles(path, args, verbose, true )
152
+
147
153
/** Compiles each source in the directory path separately by calling
148
154
* compileFile resp. compileDir. */
149
- def compileFiles (path : String , args : List [String ] = Nil , verbose : Boolean = true )
155
+ def compileFiles (path : String , args : List [String ] = Nil , verbose : Boolean = true , isRunTest : Boolean = false )
150
156
(implicit defaultOptions : List [String ]): Unit = {
151
157
val dir = Directory (path)
152
158
val fileNames = dir.files.toArray.map(_.jfile.getName).filter(name => (name endsWith " .scala" ) || (name endsWith " .java" ))
153
159
for (name <- fileNames) {
154
160
if (verbose) println(s " testing $path$name" )
155
- compileFile(path, name, args, 0 , " " )
161
+ compileFile(path, name, args, 0 , " " , isRunTest )
156
162
}
157
163
for (subdir <- dir.dirs) {
158
164
if (verbose) println(s " testing $subdir" )
159
- compileDir(path, subdir.jfile.getName, args, 0 )
165
+ compileDir(path, subdir.jfile.getName, args, 0 , isRunTest )
160
166
}
161
167
}
162
168
@@ -167,7 +173,7 @@ abstract class CompilerTest extends DottyTest {
167
173
compileArgs((files ++ args).toArray, xerrors)
168
174
} else {
169
175
val destDir = Directory (DPConfig .testRoot + JFile .separator + testName)
170
- files.foreach({ file =>
176
+ files.foreach({ file =>
171
177
val jfile = new JFile (file)
172
178
recCopyFiles(jfile, destDir / jfile.getName)
173
179
})
@@ -192,7 +198,7 @@ abstract class CompilerTest extends DottyTest {
192
198
if (runTest) " run"
193
199
else if (xerrors > 0 ) " neg"
194
200
else if (prefixDir.endsWith(" run" + JFile .separator)) {
195
- NestUI .echoWarning(" WARNING: test is being run as pos test despite being in a run directory. " +
201
+ NestUI .echoWarning(" WARNING: test is being run as pos test despite being in a run directory. " +
196
202
" Use runFile/runDir instead of compileFile/compileDir to do a run test" )
197
203
" pos"
198
204
} else " pos"
@@ -226,7 +232,7 @@ abstract class CompilerTest extends DottyTest {
226
232
computeDestAndCopyFiles(source, nextDest, kind, flags, nerr, nr + 1 , partestOutput)
227
233
}
228
234
}
229
-
235
+
230
236
/** Copies the test sources. Creates flags, nerr, check and output files. */
231
237
private def copyFiles (sourceFile : Path , dest : Path , partestOutput : String , flags : List [String ], nerr : String , kind : String ) = {
232
238
recCopyFiles(sourceFile, dest)
@@ -237,7 +243,7 @@ abstract class CompilerTest extends DottyTest {
237
243
dest.changeExtension(" flags" ).createFile(true ).writeAll(flags.mkString(" " ))
238
244
if (nerr != " 0" )
239
245
dest.changeExtension(" nerr" ).createFile(true ).writeAll(nerr)
240
- sourceFile.changeExtension(" check" ).ifFile({ check =>
246
+ sourceFile.changeExtension(" check" ).ifFile({ check =>
241
247
if (kind == " run" )
242
248
FileManager .copyFile(check.jfile, dest.changeExtension(" check" ).jfile)
243
249
else
@@ -256,7 +262,7 @@ abstract class CompilerTest extends DottyTest {
256
262
} else {
257
263
NestUI .echoWarning(s " WARNING: ignoring $sf" )
258
264
}
259
- }, { sdir =>
265
+ }, { sdir =>
260
266
dest.jfile.mkdirs
261
267
sdir.list.foreach(path => recCopyFiles(path, dest / path.name))
262
268
}, Some (" DPCompilerTest.recCopyFiles: sourceFile not found: " + sourceFile))
@@ -278,7 +284,7 @@ abstract class CompilerTest extends DottyTest {
278
284
if (! genSrc.isDefined) {
279
285
NotExists
280
286
} else {
281
- val source = processFileDir(sourceFile, { f => f.safeSlurp }, { d => Some (" " ) },
287
+ val source = processFileDir(sourceFile, { f => f.safeSlurp }, { d => Some (" " ) },
282
288
Some (" DPCompilerTest sourceFile doesn't exist: " + sourceFile)).get
283
289
if (source == genSrc) {
284
290
nerr match {
@@ -299,7 +305,7 @@ abstract class CompilerTest extends DottyTest {
299
305
val nrString = nr.toString
300
306
name match {
301
307
case nrFinder(prefix, `nrString`) => prefix + (nr + 1 )
302
- case _ =>
308
+ case _ =>
303
309
assert(nr == 0 , " DPCompilerTest couldn't create new version of files, match error" )
304
310
name + " _v1"
305
311
}
@@ -324,7 +330,7 @@ abstract class CompilerTest extends DottyTest {
324
330
Directory (prefix + dirName).deepFiles.foreach(source => recCopyFiles(source, destDir / source.name))
325
331
destDir.jfile
326
332
}
327
-
333
+
328
334
}
329
335
330
336
object CompilerTest extends App {
0 commit comments