Skip to content

Commit 57a1177

Browse files
committed
Improve summary report by dumping all to stdout on CI
1 parent 6d7c230 commit 57a1177

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ scala-scala
4444
out/
4545
build/
4646
!out/.keep
47+
testlogs/
4748

4849
# Ignore build-file
4950
.packages

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 = !sys.env.contains("DRONE")
15+
def isInteractive: Boolean = 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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* this class
1212
*/
1313
public class ParallelSummaryReport {
14+
public final static boolean isInteractive = !System.getenv().containsKey("DRONE");
15+
1416
private static TestReporter rep = TestReporter.reporter(-1);
1517
private static ArrayDeque<String> failedTests = new ArrayDeque<>();
1618
private static ArrayDeque<String> reproduceInstructions = new ArrayDeque<>();
@@ -54,14 +56,18 @@ public final static void addReproduceInstruction(String msg) {
5456
.map(x -> " " + x)
5557
.forEach(rep::echo);
5658

57-
rep.flushToStdErr();
59+
// If we're compiling locally, we don't need reproduce instructions
60+
if (isInteractive) rep.flushToStdErr();
5861

5962
rep.echo("");
6063

6164
reproduceInstructions
6265
.stream()
6366
.forEach(rep::echo);
6467

68+
// If we're on the CI, we want everything
69+
if (!isInteractive) rep.flushToStdErr();
70+
6571
if (failed > 0) rep.flushToFile();
6672
}
6773
}

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ trait ParallelTesting { self =>
5151
def outDir: JFile
5252
def flags: Array[String]
5353

54+
55+
def title: String = self match {
56+
case self: JointCompilationSource =>
57+
if (self.files.length > 1) name
58+
else self.files.head.getPath
59+
60+
case self: SeparateCompilationSource =>
61+
self.dir.getPath
62+
}
63+
5464
/** Adds the flags specified in `newFlags0` if they do not already exist */
5565
def withFlags(newFlags0: String*) = {
5666
val newFlags = newFlags0.toArray
@@ -69,7 +79,11 @@ trait ParallelTesting { self =>
6979
val maxLen = 80
7080
var lineLen = 0
7181

72-
sb.append(s"\n\nTest compiled with $errors error(s) and $warnings warning(s), the test can be reproduced by running:")
82+
sb.append(
83+
s"""|
84+
|Test '$title' compiled with $errors error(s) and $warnings warning(s),
85+
|the test can be reproduced by running:""".stripMargin
86+
)
7387
sb.append("\n\n./bin/dotc ")
7488
flags.foreach { arg =>
7589
if (lineLen > maxLen) {
@@ -447,6 +461,7 @@ trait ParallelTesting { self =>
447461
private def verifyOutput(checkFile: JFile, dir: JFile, testSource: TestSource, warnings: Int) = {
448462
val outputLines = runMain(dir, testSource)
449463
val checkLines = Source.fromFile(checkFile).getLines.toArray
464+
val sourceTitle = testSource.title
450465

451466
def linesMatch =
452467
outputLines
@@ -458,7 +473,11 @@ trait ParallelTesting { self =>
458473
val diff = outputLines.zip(checkLines).map { case (act, exp) =>
459474
DiffUtil.mkColoredLineDiff(exp, act)
460475
}.mkString("\n")
461-
val msg = s"\nOutput from run test '$checkFile' did not match expected, output:\n$diff\n"
476+
477+
val msg =
478+
s"""|Output from '$sourceTitle' did not match check file.
479+
|Diff ('e' is expected, 'a' is actual):
480+
|""".stripMargin + diff + "\n"
462481
echo(msg)
463482
addFailureInstruction(msg)
464483

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
2525
protected final val _messageBuf = mutable.ArrayBuffer.empty[String]
2626

2727
final def flushToFile(): Unit =
28-
_messageBuf.iterator.foreach(filePrintln)
28+
_messageBuf
29+
.iterator
30+
.map(_.replaceAll("\u001b\\[.*?m", ""))
31+
.foreach(filePrintln)
2932

3033
final def flushToStdErr(): Unit =
31-
_messageBuf.iterator.foreach(System.err.println)
34+
_messageBuf
35+
.iterator
36+
.map(_.replaceAll("\u001b\\[.*?m", ""))
37+
.foreach(System.err.println)
3238

3339
final def inlineInfo(pos: SourcePosition): String =
3440
if (pos.exists) {
@@ -75,10 +81,11 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
7581
}
7682

7783
object TestReporter {
78-
private[this] val logWriter = {
84+
private[this] lazy val logWriter = {
7985
val df = new SimpleDateFormat("yyyy-MM-dd-HH:mm")
8086
val timestamp = df.format(new Date)
81-
new PrintWriter(new FileOutputStream(new JFile(s"../tests-$timestamp.log"), true))
87+
new JFile("../testlogs").mkdirs()
88+
new PrintWriter(new FileOutputStream(new JFile(s"../testlogs/tests-$timestamp.log"), true))
8289
}
8390

8491
def writeToLog(str: String) = {

0 commit comments

Comments
 (0)