aboutsummaryrefslogtreecommitdiff
path: root/compiler/test/dotty/tools/vulpix
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/test/dotty/tools/vulpix')
-rw-r--r--compiler/test/dotty/tools/vulpix/ParallelTesting.scala17
-rw-r--r--compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala5
-rw-r--r--compiler/test/dotty/tools/vulpix/SummaryReport.scala29
3 files changed, 34 insertions, 17 deletions
diff --git a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala
index f43462011..b0312523d 100644
--- a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala
+++ b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala
@@ -192,8 +192,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
/** A runnable that logs its contents in a buffer */
trait LoggedRunnable extends Runnable {
- import TestReporter.logWriter
-
/** Instances of `LoggedRunnable` implement this method instead of the
* `run` method
*/
@@ -212,8 +210,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
final def run(): Unit = {
checkTestSource()
- logBuffer.iterator.foreach(logWriter.println)
- logWriter.flush()
+ summaryReport.echoToLog(logBuffer.iterator)
}
}
@@ -265,7 +262,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
private[this] val failedTestSources = mutable.ArrayBuffer.empty[String]
protected final def failTestSource(testSource: TestSource, reason: Option[String] = None) = synchronized {
val extra = reason.map(" with reason: " + _).getOrElse("")
- failedTestSources.append(testSource.title + s" failed (in ${testSource.name})" + extra)
+ failedTestSources.append(testSource.title + s" failed" + extra)
fail()
}
@@ -309,7 +306,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
protected def tryCompile(testSource: TestSource)(op: => Unit): Unit =
try {
val testing = s"Testing ${testSource.title}"
- TestReporter.logWriter.println(testing)
+ summaryReport.echoToLog(testing)
if (!isInteractive) realStdout.println(testing)
op
} catch {
@@ -519,6 +516,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
}
case Failure(output) =>
+ echo(s"Test '${testSource.title}' failed with output:")
echo(output)
failTestSource(testSource)
@@ -574,7 +572,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
if (!compilerCrashed && errorCount == 0) verifier()
else {
- echo(s"\n Compilation failed for: '$testSource'")
+ echo(s" Compilation failed for: '${testSource.title}' ")
val buildInstr = testSource.buildInstructions(errorCount, warningCount)
addFailureInstruction(buildInstr)
failTestSource(testSource)
@@ -1018,6 +1016,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
.getOrElse {
throw new IllegalStateException("Unable to reflectively find calling method")
}
+ .takeWhile(_ != '$')
}
/** Compiles a single file from the string path `f` using the supplied flags */
@@ -1072,7 +1071,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
val targetDir = new JFile(outDir + "/" + sourceDir.getName + "/")
targetDir.mkdirs()
- val target = JointCompilationSource(callingMethod, randomized, flags, targetDir)
+ val target = JointCompilationSource(s"compiling '$f' in test '$callingMethod'", randomized, flags, targetDir)
new CompilationTest(target)
}
@@ -1089,7 +1088,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
targetDir.mkdirs()
assert(targetDir.exists, s"couldn't create target directory: $targetDir")
- val target = JointCompilationSource(callingMethod, files.map(new JFile(_)).toArray, flags, targetDir)
+ val target = JointCompilationSource(s"$testName from $callingMethod", files.map(new JFile(_)).toArray, flags, targetDir)
// Create a CompilationTest and let the user decide whether to execute a pos or a neg test
new CompilationTest(target)
diff --git a/compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala b/compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala
index ad068e9ef..610466224 100644
--- a/compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala
+++ b/compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala
@@ -3,6 +3,7 @@ package tools
package vulpix
import java.io.{ File => JFile, InputStreamReader, BufferedReader, PrintStream }
+import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.TimeoutException
import scala.concurrent.duration.Duration
@@ -84,11 +85,11 @@ trait RunnerOrchestration {
}
/** Did add hook to kill the child VMs? */
- private[this] var didAddCleanupCallback = false
+ private[this] val didAddCleanupCallback = new AtomicBoolean(false)
/** Blocks less than `maxDuration` while running `Test.main` from `dir` */
def runMain(classPath: String)(implicit summaryReport: SummaryReporting): Status = {
- if (!didAddCleanupCallback) {
+ if (didAddCleanupCallback.compareAndSet(false, true)) {
// If for some reason the test runner (i.e. sbt) doesn't kill the VM, we
// need to clean up ourselves.
summaryReport.addCleanup(killAll)
diff --git a/compiler/test/dotty/tools/vulpix/SummaryReport.scala b/compiler/test/dotty/tools/vulpix/SummaryReport.scala
index 8f3047f49..678d88809 100644
--- a/compiler/test/dotty/tools/vulpix/SummaryReport.scala
+++ b/compiler/test/dotty/tools/vulpix/SummaryReport.scala
@@ -34,6 +34,12 @@ trait SummaryReporting {
/** Echo the summary report to the appropriate locations */
def echoSummary(): Unit
+
+ /** Echoes *immediately* to file */
+ def echoToLog(msg: String): Unit
+
+ /** Echoes contents of `it` to file *immediately* then flushes */
+ def echoToLog(it: Iterator[String]): Unit
}
/** A summary report that doesn't do anything */
@@ -45,6 +51,8 @@ final class NoSummaryReport extends SummaryReporting {
def addStartingMessage(msg: String): Unit = ()
def addCleanup(f: () => Unit): Unit = ()
def echoSummary(): Unit = ()
+ def echoToLog(msg: String): Unit = ()
+ def echoToLog(it: Iterator[String]): Unit = ()
}
/** A summary report that logs to both stdout and the `TestReporter.logWriter`
@@ -95,17 +103,18 @@ final class SummaryReport extends SummaryReporting {
startingMessages.foreach(rep.append)
- failedTests.map(x => " " + x).foreach(rep.append)
+ failedTests.map(x => s" $x\n").foreach(rep.append)
// If we're compiling locally, we don't need instructions on how to
// reproduce failures
if (isInteractive) {
println(rep.toString)
if (failed > 0) println {
- """|
- |----------------------------------------------------------
- |Note: reproduction instructed have been dumped to log file
- |----------------------------------------------------------""".stripMargin
+ s"""|
+ |--------------------------------------------------------------------------------
+ |Note - reproduction instructions have been dumped to log file:
+ | ${TestReporter.logPath}
+ |--------------------------------------------------------------------------------""".stripMargin
}
}
@@ -116,11 +125,19 @@ final class SummaryReport extends SummaryReporting {
// If we're on the CI, we want everything
if (!isInteractive) println(rep.toString)
- TestReporter.writeToLog(rep.toString)
+ TestReporter.logPrintln(rep.toString)
// Perform cleanup callback:
if (cleanUps.nonEmpty) cleanUps.foreach(_.apply())
}
+
+ def echoToLog(msg: String): Unit =
+ TestReporter.logPrintln(msg)
+
+ def echoToLog(it: Iterator[String]): Unit = {
+ it.foreach(TestReporter.logPrint)
+ TestReporter.logFlush()
+ }
}
object SummaryReport {