Skip to content

Commit 4e98ec6

Browse files
Failure logic moved to onFailure callback
1 parent 43b3df4 commit 4e98ec6

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
193193
testSource.compilationGroups.map(files => compile(files, flags, false, outDir)) // TODO? only `compile` option?
194194
}
195195

196-
def onSuccess(testSource: TestSource, reporters: Seq[TestReporter]): Unit = ()
197-
def onFailure(testSource: TestSource, reporters: Seq[TestReporter]): Unit = ()
196+
def onSuccess(testSource: TestSource, reporters: Seq[TestReporter], logger: LoggedRunnable): Unit = ()
197+
def onFailure(testSource: TestSource, reporters: Seq[TestReporter], logger: LoggedRunnable): Unit = {
198+
echo(s" Compilation failed for: '${testSource.title}' ")
199+
reporters.filter(reporterFailed).foreach(logger.logReporterContents)
200+
logBuildInstructions(testSource, reporters)
201+
}
198202

199203
def countErrorsAndWarnings(reporters: Seq[TestReporter]): (Int, Int) =
200204
reporters.foldLeft((0, 0)) { case ((err, warn), r) => (err + r.errorCount, warn + r.warningCount) }
@@ -203,17 +207,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
203207
def countWarnings(reporters: Seq[TestReporter]) = countErrorsAndWarnings(reporters)._2
204208
def reporterFailed(r: TestReporter) = r.compilerCrashed || r.errorCount > 0
205209

206-
protected def encapsulatedCompilation(testSource: TestSource) = new LoggedRunnable {
210+
protected def encapsulatedCompilation(testSource: TestSource) = new LoggedRunnable { self =>
207211
def checkTestSource(): Unit = tryCompile(testSource) {
208212
val reporters = compileTestSource(testSource)
209-
210-
if (!reporters.exists(reporterFailed)) onSuccess(testSource, reporters)
211-
else { onFailure(testSource, reporters)
212-
echo(s" Compilation failed for: '${testSource.title}' ")
213-
reporters.filter(reporterFailed).foreach(logReporterContents)
214-
logBuildInstructions(testSource, reporters)
215-
}
216-
registerCompletion()
213+
if (!reporters.exists(reporterFailed)) onSuccess(testSource, reporters, self)
214+
else onFailure(testSource, reporters, self)
217215
}
218216
}
219217
}
@@ -641,7 +639,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
641639
}
642640

643641

644-
override def onSuccess(testSource: TestSource, reporters: Seq[TestReporter]) =
642+
override def onSuccess(testSource: TestSource, reporters: Seq[TestReporter], logger: LoggedRunnable) =
645643
verifyOutput(checkFile(testSource), testSource.outDir, testSource, countWarnings(reporters))
646644
}
647645

0 commit comments

Comments
 (0)