Skip to content

Commit eaf9b0d

Browse files
committed
Change repoter for backend issue, revert a few synchronized blocks
1 parent b1801a4 commit eaf9b0d

File tree

4 files changed

+41
-58
lines changed

4 files changed

+41
-58
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import scala.util.matching.Regex
1212
class CompilationTests extends ParallelSummaryReport with ParallelTesting {
1313
import CompilationTests._
1414

15-
def isInteractive: Boolean = ParallelSummaryReport.isInteractive
15+
def isInteractive: Boolean = false//ParallelSummaryReport.isInteractive
1616

1717
def testFilter: Option[Regex] = sys.props.get("dotty.partest.filter").map(r => new Regex(r))
1818

compiler/test/dotty/tools/dotc/ParallelSummaryReport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class ParallelSummaryReport {
1414
public final static boolean isInteractive = !System.getenv().containsKey("DRONE");
1515

16-
private static TestReporter rep = TestReporter.reporter(-1);
16+
private static TestReporter rep = TestReporter.reporter(System.out, -1);
1717
private static ArrayDeque<String> failedTests = new ArrayDeque<>();
1818
private static ArrayDeque<String> reproduceInstructions = new ArrayDeque<>();
1919
private static int passed;
@@ -36,7 +36,7 @@ public final static void addReproduceInstruction(String msg) {
3636
}
3737

3838
@BeforeClass public final static void setup() {
39-
rep = TestReporter.reporter(-1);
39+
rep = TestReporter.reporter(System.out, -1);
4040
failedTests = new ArrayDeque<>();
4141
reproduceInstructions = new ArrayDeque<>();
4242
}

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

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,8 @@ trait ParallelTesting { self =>
229229
}
230230

231231
/** Prints to `System.err` if we're not suppressing all output */
232-
protected def echo(msg: String): Unit = realStderr.synchronized {
232+
protected def echo(msg: String): Unit =
233233
if (!suppressAllOutput) realStderr.println(msg)
234-
}
235234

236235
/** A single `Runnable` that prints a progress bar for the curent `Test` */
237236
private def createProgressMonitor: Runnable = new Runnable {
@@ -242,14 +241,12 @@ trait ParallelTesting { self =>
242241
val timestamp = (System.currentTimeMillis - start) / 1000
243242
val progress = (tCompiled.toDouble / sourceCount * 40).toInt
244243

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-
}
244+
realStdout.print(
245+
"[" + ("=" * (math.max(progress - 1, 0))) +
246+
(if (progress > 0) ">" else "") +
247+
(" " * (39 - progress)) +
248+
s"] compiling ($tCompiled/$sourceCount, ${timestamp}s)\r"
249+
)
253250

254251
Thread.sleep(100)
255252
tCompiled = testSourcesCompiled
@@ -267,9 +264,7 @@ trait ParallelTesting { self =>
267264
*/
268265
protected def tryCompile(testSource: TestSource)(op: => Unit): Unit =
269266
try {
270-
if (!isInteractive) realStdout.synchronized {
271-
realStdout.println(s"Testing ${testSource.title}")
272-
}
267+
if (!isInteractive) realStdout.println(s"Testing ${testSource.title}")
273268
op
274269
} catch {
275270
case NonFatal(e) => {
@@ -321,10 +316,10 @@ trait ParallelTesting { self =>
321316
Runtime.getRuntime.exec(fullArgs).waitFor() == 0
322317
} else true
323318

324-
val reporter = System.out.synchronized {
325-
TestReporter.parallelReporter(System.out, logLevel =
319+
val reporter =
320+
TestReporter.reporter(realStdout, logLevel =
326321
if (suppressErrors || suppressAllOutput) ERROR + 1 else ERROR)
327-
}
322+
328323
val driver =
329324
if (times == 1) new Driver { def newCompiler(implicit ctx: Context) = new Compiler }
330325
else new Driver {
@@ -431,16 +426,14 @@ trait ParallelTesting { self =>
431426
import java.net.{ URL, URLClassLoader }
432427

433428
val printStream = new ByteArrayOutputStream
434-
val oldOut = System.out
435-
val oldErr = System.err
436429

437430
try {
438431
// Do classloading magic and running here:
439432
val ucl = new URLClassLoader(Array(dir.toURI.toURL))
440433
val cls = ucl.loadClass("Test")
441434
val meth = cls.getMethod("main", classOf[Array[String]])
442435

443-
oldOut.synchronized {
436+
synchronized {
444437
try {
445438
val ps = new PrintStream(printStream)
446439
System.setOut(ps)
@@ -450,12 +443,12 @@ trait ParallelTesting { self =>
450443
meth.invoke(null, Array("jvm")) // partest passes at least "jvm" as an arg
451444
}
452445
}
453-
System.setOut(oldOut)
454-
System.setErr(oldErr)
446+
System.setOut(realStdout)
447+
System.setErr(realStderr)
455448
} catch {
456449
case t: Throwable =>
457-
System.setOut(oldOut)
458-
System.setErr(oldErr)
450+
System.setOut(realStdout)
451+
System.setErr(realStderr)
459452
throw t
460453
}
461454
}

compiler/test/dotty/tools/dotc/reporting/TestReporter.scala

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools
22
package dotc
33
package reporting
44

5-
import java.io.{ PrintWriter, File => JFile, FileOutputStream }
5+
import java.io.{ PrintStream, PrintWriter, File => JFile, FileOutputStream }
66
import java.text.SimpleDateFormat
77
import java.util.Date
88

@@ -15,7 +15,7 @@ import diagnostic.{ Message, MessageContainer, NoExplanation }
1515
import diagnostic.messages._
1616
import interfaces.Diagnostic.{ ERROR, WARNING, INFO }
1717

18-
class TestReporter protected (outWriter: () => PrintWriter, filePrintln: String => Unit, logLevel: Int)
18+
class TestReporter protected (outWriter: PrintWriter, filePrintln: String => Unit, logLevel: Int)
1919
extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with MessageRendering {
2020
import MessageContainer._
2121

@@ -53,8 +53,8 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
5353
val extraInfo = inlineInfo(m.pos)
5454

5555
if (m.level >= logLevel) {
56-
outWriter().println(msg)
57-
if (extraInfo.nonEmpty) outWriter().println(extraInfo)
56+
outWriter.println(msg)
57+
if (extraInfo.nonEmpty) outWriter.println(extraInfo)
5858
}
5959

6060
_messageBuf.append(msg)
@@ -93,35 +93,25 @@ object TestReporter {
9393
logWriter.flush()
9494
}
9595

96-
def parallelReporter(lock: AnyRef, logLevel: Int): TestReporter = new TestReporter(
97-
() => lock.synchronized { new PrintWriter(Console.err, true) },
98-
str => lock.synchronized { writeToLog(str) },
99-
logLevel
100-
)
101-
102-
def reporter(logLevel: Int): TestReporter = new TestReporter(
103-
() => new PrintWriter(Console.err, true),
104-
writeToLog,
105-
logLevel
106-
)
107-
108-
def simplifiedReporter(writer: PrintWriter): TestReporter = new TestReporter(
109-
() => writer,
110-
writeToLog,
111-
WARNING
112-
) {
113-
/** Prints the message with the given position indication in a simplified manner */
114-
override def printMessageAndPos(m: MessageContainer, extra: String)(implicit ctx: Context): Unit = {
115-
val msg = s"${m.pos.line + 1}: " + m.contained.kind + extra
116-
val extraInfo = inlineInfo(m.pos)
117-
118-
writer.println(msg)
119-
_messageBuf.append(msg)
120-
121-
if (extraInfo.nonEmpty) {
122-
writer.println(extraInfo)
123-
_messageBuf.append(extraInfo)
96+
def reporter(ps: PrintStream, logLevel: Int): TestReporter =
97+
new TestReporter(new PrintWriter(ps, true), writeToLog, logLevel)
98+
99+
def simplifiedReporter(writer: PrintWriter): TestReporter = {
100+
val rep = new TestReporter(writer, writeToLog, WARNING) {
101+
/** Prints the message with the given position indication in a simplified manner */
102+
override def printMessageAndPos(m: MessageContainer, extra: String)(implicit ctx: Context): Unit = {
103+
val msg = s"${m.pos.line + 1}: " + m.contained.kind + extra
104+
val extraInfo = inlineInfo(m.pos)
105+
106+
writer.println(msg)
107+
_messageBuf.append(msg)
108+
109+
if (extraInfo.nonEmpty) {
110+
writer.println(extraInfo)
111+
_messageBuf.append(extraInfo)
112+
}
124113
}
125114
}
115+
rep
126116
}
127117
}

0 commit comments

Comments
 (0)