Skip to content

Commit b1df7fc

Browse files
committed
Use original check file for easier update
1 parent e326612 commit b1df7fc

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
582582
private final class PosTest(testSources: List[TestSource], times: Int, threadLimit: Option[Int], suppressAllOutput: Boolean)(implicit summaryReport: SummaryReporting)
583583
extends Test(testSources, times, threadLimit, suppressAllOutput)
584584

585-
private final class RewriteTest(testSources: List[TestSource], times: Int, threadLimit: Option[Int], suppressAllOutput: Boolean)(implicit summaryReport: SummaryReporting)
585+
private final class RewriteTest(testSources: List[TestSource], checkFiles: Map[JFile, JFile], times: Int, threadLimit: Option[Int], suppressAllOutput: Boolean)(implicit summaryReport: SummaryReporting)
586586
extends Test(testSources, times, threadLimit, suppressAllOutput) {
587587
private def verifyOutput(testSource: TestSource, reporters: Seq[TestReporter], logger: LoggedRunnable) = {
588588
testSource.sourceFiles.foreach { file =>
589-
val checkFile = new JFile(file.getPath.replaceFirst("\\.scala$", ".check"))
590-
if checkFile.exists then
589+
if checkFiles.contains(file) then
590+
val checkFile = checkFiles(file)
591591
val actual = Source.fromFile(file, "UTF-8").getLines().toList
592592
diffTest(testSource, checkFile, actual, reporters, logger)
593593
}
@@ -937,17 +937,28 @@ trait ParallelTesting extends RunnerOrchestration { self =>
937937

938938
/** Tests `-rewrite`, which makes sure that the rewritten files still compile
939939
* and agree with the expected result (if specified).
940+
*
941+
* Check files are only supported for joint compilation sources.
940942
*/
941943
def checkRewrites()(implicit summaryReport: SummaryReporting): this.type = {
944+
// use the original check file, to simplify update of check files
945+
var checkFileMap = Map.empty[JFile, JFile]
946+
942947
// copy source file to targets, as they will be changed
943948
val copiedTargets = targets.map {
944949
case target @ JointCompilationSource(_, files, _, outDir, _, _) =>
945-
target.copy(files = files.map(copyToDir(outDir,_)))
950+
val files2 = files.map { f =>
951+
val dest = copyToDir(outDir, f)
952+
val checkFile = new JFile(f.getPath.replaceFirst("\\.scala$", ".check"))
953+
if (checkFile.exists) checkFileMap = checkFileMap.updated(dest, checkFile)
954+
dest
955+
}
956+
target.copy(files = files2)
946957
case target @ SeparateCompilationSource(_, dir, _, outDir) =>
947958
target.copy(dir = copyToDir(outDir, dir))
948959
}
949960

950-
val test = new RewriteTest(copiedTargets, times, threadLimit, shouldFail || shouldSuppressOutput).executeTestSuite()
961+
val test = new RewriteTest(copiedTargets, checkFileMap, times, threadLimit, shouldFail || shouldSuppressOutput).executeTestSuite()
951962
this
952963
}
953964

0 commit comments

Comments
 (0)