aboutsummaryrefslogtreecommitdiff
path: root/compiler/test/dotty/tools/dotc
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-03-29 13:29:28 +0200
committerFelix Mulder <felix.mulder@gmail.com>2017-03-29 14:52:20 +0200
commit02ebe0f9b18b7dec024b79109ecf984d23c15cd1 (patch)
treeb73e1f5d04167b9a089c1cf69b84d81f22241d86 /compiler/test/dotty/tools/dotc
parentb5b6f5ea98628b005b00bfa515d2e13d644d8435 (diff)
downloaddotty-02ebe0f9b18b7dec024b79109ecf984d23c15cd1.tar.gz
dotty-02ebe0f9b18b7dec024b79109ecf984d23c15cd1.tar.bz2
dotty-02ebe0f9b18b7dec024b79109ecf984d23c15cd1.zip
Make summary report come at the end of test suite
Diffstat (limited to 'compiler/test/dotty/tools/dotc')
-rw-r--r--compiler/test/dotty/tools/dotc/CompilationTests.scala2
-rw-r--r--compiler/test/dotty/tools/dotc/ParallelSummaryReport.java67
-rw-r--r--compiler/test/dotty/tools/dotc/ParallelTesting.scala24
-rw-r--r--compiler/test/dotty/tools/dotc/reporting/TestReporter.scala12
4 files changed, 84 insertions, 21 deletions
diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala
index 74688c24d..788e30aa3 100644
--- a/compiler/test/dotty/tools/dotc/CompilationTests.scala
+++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala
@@ -9,7 +9,7 @@ import org.junit.experimental.categories.Category
import scala.util.matching.Regex
@Category(Array(classOf[ParallelTesting]))
-class CompilationTests extends ParallelTesting {
+class CompilationTests extends ParallelSummaryReport with ParallelTesting {
import CompilationTests._
def isInteractive: Boolean = !sys.env.contains("DRONE")
diff --git a/compiler/test/dotty/tools/dotc/ParallelSummaryReport.java b/compiler/test/dotty/tools/dotc/ParallelSummaryReport.java
new file mode 100644
index 000000000..9214e7d25
--- /dev/null
+++ b/compiler/test/dotty/tools/dotc/ParallelSummaryReport.java
@@ -0,0 +1,67 @@
+package dotty.tools.dotc;
+
+import org.junit.BeforeClass;
+import org.junit.AfterClass;
+import java.util.ArrayDeque;
+
+import dotty.tools.dotc.reporting.TestReporter;
+import dotty.tools.dotc.reporting.TestReporter$;
+
+/** Note that while `ParallelTesting` runs in parallel, JUnit tests cannot with
+ * this class
+ */
+public class ParallelSummaryReport {
+ private static TestReporter rep = TestReporter.reporter(-1);
+ private static ArrayDeque<String> failedTests = new ArrayDeque<>();
+ private static ArrayDeque<String> reproduceInstructions = new ArrayDeque<>();
+ private static int passed;
+ private static int failed;
+
+ public final static void reportFailed() {
+ failed++;
+ }
+
+ public final static void reportPassed() {
+ passed++;
+ }
+
+ public final static void addFailedTest(String msg) {
+ failedTests.offer(msg);
+ }
+
+ public final static void addReproduceInstruction(String msg) {
+ reproduceInstructions.offer(msg);
+ }
+
+ @BeforeClass public final static void setup() {
+ rep = TestReporter.reporter(-1);
+ failedTests = new ArrayDeque<>();
+ reproduceInstructions = new ArrayDeque<>();
+ }
+
+ @AfterClass public final static void teardown() {
+ rep.echo(
+ "\n================================================================================" +
+ "\nTest Report" +
+ "\n================================================================================" +
+ "\n" +
+ passed + " passed, " + failed + " failed, " + (passed + failed) + " total" +
+ "\n"
+ );
+
+ failedTests
+ .stream()
+ .map(x -> " " + x)
+ .forEach(rep::echo);
+
+ rep.flushToStdErr();
+
+ rep.echo("");
+
+ reproduceInstructions
+ .stream()
+ .forEach(rep::echo);
+
+ if (failed > 0) rep.flushToFile();
+ }
+}
diff --git a/compiler/test/dotty/tools/dotc/ParallelTesting.scala b/compiler/test/dotty/tools/dotc/ParallelTesting.scala
index 016e8770f..30679de9e 100644
--- a/compiler/test/dotty/tools/dotc/ParallelTesting.scala
+++ b/compiler/test/dotty/tools/dotc/ParallelTesting.scala
@@ -31,6 +31,7 @@ import dotc.util.DiffUtil
trait ParallelTesting {
import ParallelTesting._
+ import ParallelSummaryReport._
/** If the running environment supports an interactive terminal, each `Test`
* will be run with a progress bar and real time feedback
@@ -197,11 +198,8 @@ trait ParallelTesting {
val errorMsg = testSource.buildInstructions(reporter.errorCount, reporter.warningCount)
addFailureInstruction(errorMsg)
failTestSource(testSource)
- reporter.echo(errorMsg)
- reporter.flushToFile()
}
-
/** Instructions on how to reproduce failed test source compilations */
private[this] val reproduceInstructions = mutable.ArrayBuffer.empty[String]
protected final def addFailureInstruction(ins: String): Unit =
@@ -210,7 +208,7 @@ trait ParallelTesting {
/** The test sources that failed according to the implementing subclass */
private[this] val failedTestSources = mutable.ArrayBuffer.empty[String]
protected final def failTestSource(testSource: TestSource) = synchronized {
- failedTestSources.append(testSource.name)
+ failedTestSources.append(testSource.name + " failed")
fail()
}
@@ -345,21 +343,11 @@ trait ParallelTesting {
throw new TimeoutException("Compiling targets timed out")
if (didFail) {
- echo {
- """|
- |
- |
- |================================================================================
- |Test Report
- |================================================================================
- |Failing tests:""".stripMargin
- }
- failedTestSources.toSet.foreach { source: String =>
- echo(" " + source)
- }
- echo("")
- reproduceInstructions.iterator.foreach(echo)
+ reportFailed()
+ failedTestSources.toSet.foreach(addFailedTest)
+ reproduceInstructions.iterator.foreach(addReproduceInstruction)
}
+ else reportPassed()
}
else echo {
testFilter
diff --git a/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala b/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala
index b37d9cd07..521cf9576 100644
--- a/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala
+++ b/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala
@@ -27,6 +27,9 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
final def flushToFile(): Unit =
_messageBuf.iterator.foreach(filePrintln)
+ final def flushToStdErr(): Unit =
+ _messageBuf.iterator.foreach(System.err.println)
+
final def inlineInfo(pos: SourcePosition): String =
if (pos.exists) {
if (pos.outer.exists)
@@ -78,6 +81,11 @@ object TestReporter {
new PrintWriter(new FileOutputStream(new JFile(s"../tests-$timestamp.log"), true))
}
+ def writeToLog(str: String) = {
+ logWriter.println(str)
+ logWriter.flush()
+ }
+
def parallelReporter(lock: AnyRef, logLevel: Int): TestReporter = new TestReporter(
new PrintWriter(Console.err, true),
str => lock.synchronized {
@@ -89,13 +97,13 @@ object TestReporter {
def reporter(logLevel: Int): TestReporter = new TestReporter(
new PrintWriter(Console.err, true),
- logWriter.println,
+ writeToLog,
logLevel
)
def simplifiedReporter(writer: PrintWriter): TestReporter = new TestReporter(
writer,
- logWriter.println,
+ writeToLog,
WARNING
) {
/** Prints the message with the given position indication in a simplified manner */