Skip to content

Commit ebd1670

Browse files
committed
Remove duplication with run test output verification
1 parent 7c42277 commit ebd1670

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

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

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,13 @@ trait ParallelTesting extends RunnerOrchestration { self =>
482482
}
483483
}
484484

485-
private def verifyOutput(checkFile: JFile, dir: JFile, testSource: TestSource, warnings: Int) = {
485+
private def verifyOutput(checkFile: Option[JFile], dir: JFile, testSource: TestSource, warnings: Int) = {
486486
if (Properties.testsNoRun) addNoRunWarning()
487487
else runMain(testSource.classPath) match {
488+
case Success(_) if !checkFile.isDefined || !checkFile.get.exists => // success!
488489
case Success(output) => {
489490
val outputLines = output.lines.toArray
490-
val checkLines: Array[String] = Source.fromFile(checkFile).getLines.toArray
491+
val checkLines: Array[String] = Source.fromFile(checkFile.get).getLines.toArray
491492
val sourceTitle = testSource.title
492493

493494
def linesMatch =
@@ -529,7 +530,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
529530

530531
protected def encapsulatedCompilation(testSource: TestSource) = new LoggedRunnable {
531532
def checkTestSource(): Unit = tryCompile(testSource) {
532-
val (compilerCrashed, errorCount, warningCount, hasCheckFile, verifier: Function0[Unit]) = testSource match {
533+
val (compilerCrashed, errorCount, warningCount, verifier: Function0[Unit]) = testSource match {
533534
case testSource @ JointCompilationSource(_, files, flags, outDir) => {
534535
val checkFile = files.flatMap { file =>
535536
if (file.isDirectory) Nil
@@ -547,7 +548,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
547548
logBuildInstructions(reporter, testSource, reporter.errorCount, reporter.warningCount)
548549
}
549550

550-
(reporter.compilerCrashed, reporter.errorCount, reporter.warningCount, checkFile.isDefined, () => verifyOutput(checkFile.get, outDir, testSource, reporter.warningCount))
551+
(reporter.compilerCrashed, reporter.errorCount, reporter.warningCount, () => verifyOutput(checkFile, outDir, testSource, reporter.warningCount))
551552
}
552553

553554
case testSource @ SeparateCompilationSource(_, dir, flags, outDir) => {
@@ -567,24 +568,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
567568
logBuildInstructions(reporters.head, testSource, errorCount, warningCount)
568569
}
569570

570-
(compilerCrashed, errorCount, warningCount, checkFile.exists, () => verifyOutput(checkFile, outDir, testSource, warningCount))
571+
(compilerCrashed, errorCount, warningCount, () => verifyOutput(Some(checkFile), outDir, testSource, warningCount))
571572
}
572573
}
573574

574-
if (!compilerCrashed && errorCount == 0 && hasCheckFile) verifier()
575-
else if (!compilerCrashed && errorCount == 0) {
576-
if (Properties.testsNoRun) addNoRunWarning()
577-
else runMain(testSource.classPath) match {
578-
case Success(_) => // success!
579-
case Failure(output) =>
580-
echo(s" failed when running '${testSource.title}'")
581-
echo(output)
582-
failTestSource(testSource)
583-
case Timeout =>
584-
echo(" failed because test " + testSource.title + " timed out")
585-
failTestSource(testSource, Some("test timed out"))
586-
}
587-
}
575+
if (!compilerCrashed && errorCount == 0) verifier()
588576
else {
589577
echo(s"\n Compilation failed for: '$testSource'")
590578
val buildInstr = testSource.buildInstructions(errorCount, warningCount)

0 commit comments

Comments
 (0)