Skip to content

Commit 4078f2c

Browse files
committed
Add ability to compile single files
1 parent 268ed4c commit 4078f2c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

compiler/test/dotty/tools/dotc/ParallelTesting.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ trait ParallelTesting {
272272
}
273273

274274
private def requirements(f: String, sourceDir: JFile, outDir: String): Unit = {
275-
require(f.contains("/tests"), "only allowed to run integration tests from `tests` dir using this method")
276275
require(sourceDir.isDirectory && sourceDir.exists, "passed non-directory to `compileFilesInDir`")
277276
require(outDir.last == '/', "please specify an `outDir` with a trailing slash")
278277
}
@@ -283,6 +282,22 @@ trait ParallelTesting {
283282
else (dirs, f :: files)
284283
}
285284

285+
def compileFileInDir(f: String, flags: Array[String])(implicit outDirectory: String): CompilationTest = {
286+
// each calling method gets its own unique output directory, in which we
287+
// place the dir being compiled:
288+
val callingMethod = Thread.currentThread.getStackTrace.apply(3).getMethodName
289+
val outDir = outDirectory + callingMethod + "/"
290+
val sourceFile = new JFile(f)
291+
val parent = sourceFile.getParentFile
292+
require(
293+
sourceFile.exists && !sourceFile.isDirectory &&
294+
(parent ne null) && parent.exists && parent.isDirectory,
295+
s"Source file: $f, didn't exist"
296+
)
297+
298+
new CompilationTest(toCompilerDirFromFile(sourceFile, parent, outDir) :: Nil, f, flags)
299+
}
300+
286301
def compileFilesInDir(f: String, flags: Array[String])(implicit outDirectory: String): CompilationTest = {
287302
// each calling method gets its own unique output directory, in which we
288303
// place the dir being compiled:

0 commit comments

Comments
 (0)