@@ -174,6 +174,8 @@ trait ParallelTesting { self =>
174
174
* according to the implementing class "neg", "run" or "pos".
175
175
*/
176
176
private abstract class Test (testSources : List [TestSource ], times : Int , threadLimit : Option [Int ], suppressAllOutput : Boolean ) {
177
+ protected final val realStdout = System .out
178
+ protected final val realStderr = System .err
177
179
178
180
/** Actual compilation run logic, the test behaviour is defined here */
179
181
protected def compilationRunnable (testSource : TestSource ): Runnable
@@ -192,10 +194,10 @@ trait ParallelTesting { self =>
192
194
val sourceCount = filteredSources.length
193
195
194
196
private [this ] var _errorCount = 0
195
- def errorCount : Int = synchronized { _errorCount }
197
+ def errorCount : Int = _errorCount
196
198
197
199
private [this ] var _testSourcesCompiled = 0
198
- private def testSourcesCompiled : Int = synchronized { _testSourcesCompiled }
200
+ private def testSourcesCompiled : Int = _testSourcesCompiled
199
201
200
202
/** Complete the current compilation with the amount of errors encountered */
201
203
protected final def registerCompilation (errors : Int ) = synchronized {
@@ -227,8 +229,9 @@ trait ParallelTesting { self =>
227
229
}
228
230
229
231
/** Prints to `System.err` if we're not suppressing all output */
230
- protected def echo (msg : String ): Unit =
231
- if (! suppressAllOutput) System .err.println(msg)
232
+ protected def echo (msg : String ): Unit = realStderr.synchronized {
233
+ if (! suppressAllOutput) realStderr.println(msg)
234
+ }
232
235
233
236
/** A single `Runnable` that prints a progress bar for the curent `Test` */
234
237
private def createProgressMonitor : Runnable = new Runnable {
@@ -238,17 +241,21 @@ trait ParallelTesting { self =>
238
241
while (tCompiled < sourceCount) {
239
242
val timestamp = (System .currentTimeMillis - start) / 1000
240
243
val progress = (tCompiled.toDouble / sourceCount * 40 ).toInt
241
- print(
242
- " [" + (" =" * (math.max(progress - 1 , 0 ))) +
243
- (if (progress > 0 ) " >" else " " ) +
244
- (" " * (39 - progress)) +
245
- s " ] compiling ( $tCompiled/ $sourceCount, ${timestamp}s) \r "
246
- )
244
+
245
+ realStdout.synchronized {
246
+ realStdout.print(
247
+ " [" + (" =" * (math.max(progress - 1 , 0 ))) +
248
+ (if (progress > 0 ) " >" else " " ) +
249
+ (" " * (39 - progress)) +
250
+ s " ] compiling ( $tCompiled/ $sourceCount, ${timestamp}s) \r "
251
+ )
252
+ }
253
+
247
254
Thread .sleep(100 )
248
255
tCompiled = testSourcesCompiled
249
256
}
250
257
// println, otherwise no newline and cursor at start of line
251
- println(
258
+ realStdout. println(
252
259
s " [=======================================] compiled ( $sourceCount/ $sourceCount, " +
253
260
s " ${(System .currentTimeMillis - start) / 1000 }s) "
254
261
)
@@ -259,7 +266,12 @@ trait ParallelTesting { self =>
259
266
* if it did, the test should automatically fail.
260
267
*/
261
268
protected def tryCompile (testSource : TestSource )(op : => Unit ): Unit =
262
- try op catch {
269
+ try {
270
+ if (! isInteractive) realStdout.synchronized {
271
+ realStdout.println(s " Testing ${testSource.title}" )
272
+ }
273
+ op
274
+ } catch {
263
275
case NonFatal (e) => {
264
276
// if an exception is thrown during compilation, the complete test
265
277
// run should fail
@@ -309,8 +321,10 @@ trait ParallelTesting { self =>
309
321
Runtime .getRuntime.exec(fullArgs).waitFor() == 0
310
322
} else true
311
323
312
- val reporter = TestReporter .parallelReporter(self, logLevel =
313
- if (suppressErrors || suppressAllOutput) ERROR + 1 else ERROR )
324
+ val reporter = System .out.synchronized {
325
+ TestReporter .parallelReporter(System .out, logLevel =
326
+ if (suppressErrors || suppressAllOutput) ERROR + 1 else ERROR )
327
+ }
314
328
val driver =
315
329
if (times == 1 ) new Driver { def newCompiler (implicit ctx : Context ) = new Compiler }
316
330
else new Driver {
@@ -426,7 +440,7 @@ trait ParallelTesting { self =>
426
440
val cls = ucl.loadClass(" Test" )
427
441
val meth = cls.getMethod(" main" , classOf [Array [String ]])
428
442
429
- self .synchronized {
443
+ oldOut .synchronized {
430
444
try {
431
445
val ps = new PrintStream (printStream)
432
446
System .setOut(ps)
0 commit comments