Skip to content

Commit 64db05b

Browse files
committed
Fix #2244: make sure logging goes through appropriate interface
1 parent 7e33bc4 commit 64db05b

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
192192

193193
/** A runnable that logs its contents in a buffer */
194194
trait LoggedRunnable extends Runnable {
195-
import TestReporter.logWriter
196-
197195
/** Instances of `LoggedRunnable` implement this method instead of the
198196
* `run` method
199197
*/
@@ -212,8 +210,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
212210

213211
final def run(): Unit = {
214212
checkTestSource()
215-
logBuffer.iterator.foreach(logWriter.println)
216-
logWriter.flush()
213+
summaryReport.echoToLog(logBuffer.iterator)
217214
}
218215
}
219216

@@ -309,7 +306,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
309306
protected def tryCompile(testSource: TestSource)(op: => Unit): Unit =
310307
try {
311308
val testing = s"Testing ${testSource.title}"
312-
TestReporter.logWriter.println(testing)
309+
summaryReport.echoToLog(testing)
313310
if (!isInteractive) realStdout.println(testing)
314311
op
315312
} catch {

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ trait SummaryReporting {
3434

3535
/** Echo the summary report to the appropriate locations */
3636
def echoSummary(): Unit
37+
38+
/** Echoes *immediately* to file */
39+
def echoToLog(msg: String): Unit
40+
41+
/** Echoes contents of `it` to file *immediately* then flushes */
42+
def echoToLog(it: Iterator[String]): Unit
3743
}
3844

3945
/** A summary report that doesn't do anything */
@@ -45,6 +51,8 @@ final class NoSummaryReport extends SummaryReporting {
4551
def addStartingMessage(msg: String): Unit = ()
4652
def addCleanup(f: () => Unit): Unit = ()
4753
def echoSummary(): Unit = ()
54+
def echoToLog(msg: String): Unit = ()
55+
def echoToLog(it: Iterator[String]): Unit = ()
4856
}
4957

5058
/** A summary report that logs to both stdout and the `TestReporter.logWriter`
@@ -122,6 +130,14 @@ final class SummaryReport extends SummaryReporting {
122130
// Perform cleanup callback:
123131
if (cleanUps.nonEmpty) cleanUps.foreach(_.apply())
124132
}
133+
134+
def echoToLog(msg: String): Unit =
135+
TestReporter.logPrintln(msg)
136+
137+
def echoToLog(it: Iterator[String]): Unit = {
138+
it.foreach(TestReporter.logPrint)
139+
TestReporter.logFlush()
140+
}
125141
}
126142

127143
object SummaryReport {

0 commit comments

Comments
 (0)