Skip to content

Commit b4fef61

Browse files
committed
Refactor code
1 parent 3b30500 commit b4fef61

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -765,10 +765,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
765765
}
766766
}
767767
def checkFileTest(sourceName: String, checkFile: JFile, actual: List[String]) = {
768-
if (checkFile.exists) {
769-
val expexted = Source.fromFile(checkFile, "UTF-8").getLines().toList
770-
diffMessage(sourceName, actual, expexted).foreach(fail)
771-
}
768+
val expexted = Source.fromFile(checkFile, "UTF-8").getLines().toList
769+
diffMessage(sourceName, actual, expexted).foreach(fail)
772770
}
773771

774772
val (compilerCrashed, expectedErrors, actualErrors, hasMissingAnnotations, errorMap) = testSource match {
@@ -778,10 +776,10 @@ trait ParallelTesting extends RunnerOrchestration { self =>
778776
val reporter = compile(sourceFiles, flags, true, outDir)
779777
val actualErrors = reporter.errorCount
780778
files.foreach { file =>
781-
if (file.isDirectory) Nil
782-
else {
783-
val checkFile = new JFile(file.getAbsolutePath.reverse.dropWhile(_ != '.').reverse + "check")
784-
checkFileTest(testSource.title, checkFile, reporterOutputLines(reporter))
779+
if (!file.isDirectory) {
780+
val checkFile = new JFile(file.getAbsolutePath.replaceFirst("\\.scala$", ".check"))
781+
if (checkFile.exists)
782+
checkFileTest(testSource.title, checkFile, reporterOutputLines(reporter))
785783
}
786784
}
787785
if (reporter.compilerCrashed || actualErrors > 0)
@@ -800,8 +798,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
800798
if (actualErrors > 0)
801799
reporters.foreach(logReporterContents)
802800

803-
val checkFile = new JFile(dir.getAbsolutePath.reverse.dropWhile(_ == JFile.separatorChar).reverse + ".check")
804-
checkFileTest(testSource.title, checkFile, reporters.flatMap(reporter => reporterOutputLines(reporter)))
801+
val checkFile = new JFile(dir.getAbsolutePath + ".check")
802+
if (checkFile.exists)
803+
checkFileTest(testSource.title, checkFile, reporters.flatMap(reporter => reporterOutputLines(reporter)))
805804

806805
(compilerCrashed, expectedErrors, actualErrors, () => getMissingExpectedErrors(errorMap, errors), errorMap)
807806
}

0 commit comments

Comments
 (0)