From 0df3f618b2540ec0c87d16ef911f2f77bbe1b327 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Mon, 20 Mar 2017 15:44:10 +0100 Subject: Support copyToDir for tests that mutate original source --- .../test/dotty/tools/dotc/ParallelTesting.scala | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'compiler/test/dotty/tools/dotc/ParallelTesting.scala') diff --git a/compiler/test/dotty/tools/dotc/ParallelTesting.scala b/compiler/test/dotty/tools/dotc/ParallelTesting.scala index 0cb6e8d7c..c9b9a8f64 100644 --- a/compiler/test/dotty/tools/dotc/ParallelTesting.scala +++ b/compiler/test/dotty/tools/dotc/ParallelTesting.scala @@ -479,6 +479,23 @@ trait ParallelTesting { this } + private def copyToDir(dir: JFile, file: JFile): JFile = { + val target = Paths.get(dir.getAbsolutePath, file.getName) + Files.copy(file.toPath, target, REPLACE_EXISTING) + if (file.isDirectory) file.listFiles.map(copyToDir(target.toFile, _)) + target.toFile + } + + def copyToTarget(): CompilationTest = new CompilationTest ( + targets.map { + case target @ ConcurrentCompilationTarget(files, _, outDir) => + target.copy(files = files.map(copyToDir(outDir,_))) + case target @ SeparateCompilationTarget(dir, _, outDir) => + target.copy(dir = copyToDir(outDir, dir)) + }, + times, shouldDelete, threadLimit + ) + def times(i: Int): CompilationTest = new CompilationTest(targets, i, shouldDelete, threadLimit) @@ -521,12 +538,6 @@ trait ParallelTesting { targetDir } - private def copyToDir(dir: JFile, file: JFile): Unit = { - val target = Paths.get(dir.getAbsolutePath, file.getName) - Files.copy(file.toPath, target, REPLACE_EXISTING) - if (file.isDirectory) file.listFiles.map(copyToDir(target.toFile, _)) - } - private def requirements(f: String, sourceDir: JFile, outDir: String): Unit = { require(sourceDir.isDirectory && sourceDir.exists, "passed non-directory to `compileFilesInDir`") require(outDir.last == '/', "please specify an `outDir` with a trailing slash") -- cgit v1.2.3