Skip to content

Various vulpix fixes #2248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ class CompilationTests extends ParallelTesting {
val opt = Array(
"-classpath",
// compile with bootstrapped library on cp:
defaultOutputDir + "lib$1/src/:" +
defaultOutputDir + "lib/src/:" +
// as well as bootstrapped compiler:
defaultOutputDir + "dotty1$1/dotty/:" +
defaultOutputDir + "dotty1/dotty/:" +
Jars.dottyInterfaces
)

Expand Down
28 changes: 23 additions & 5 deletions compiler/test/dotty/tools/dotc/reporting/TestReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,41 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
}

object TestReporter {
val logWriter = {
private[this] var outFile: JFile = _
private[this] var logWriter: PrintWriter = _

private[this] def initLog() = if (logWriter eq null) {
val df = new SimpleDateFormat("yyyy-MM-dd-HH:mm")
val timestamp = df.format(new Date)
new JFile("../testlogs").mkdirs()
new PrintWriter(new FileOutputStream(new JFile(s"../testlogs/tests-$timestamp.log"), true))
outFile = new JFile(s"../testlogs/tests-$timestamp.log")
logWriter = new PrintWriter(new FileOutputStream(outFile, true))
}

def writeToLog(str: String) = {
def logPrintln(str: String) = {
initLog()
logWriter.println(str)
logWriter.flush()
}

def logPrint(str: String): Unit = {
initLog()
logWriter.println(str)
}

def logFlush(): Unit =
if (logWriter ne null) logWriter.flush()

def logPath: String = {
initLog()
outFile.getCanonicalPath
}

def reporter(ps: PrintStream, logLevel: Int): TestReporter =
new TestReporter(new PrintWriter(ps, true), writeToLog, logLevel)
new TestReporter(new PrintWriter(ps, true), logPrintln, logLevel)

def simplifiedReporter(writer: PrintWriter): TestReporter = {
val rep = new TestReporter(writer, writeToLog, WARNING) {
val rep = new TestReporter(writer, logPrintln, WARNING) {
/** Prints the message with the given position indication in a simplified manner */
override def printMessageAndPos(m: MessageContainer, extra: String)(implicit ctx: Context): Unit = {
def report() = {
Expand Down
17 changes: 8 additions & 9 deletions compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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()
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -519,6 +516,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
}

case Failure(output) =>
echo(s"Test '${testSource.title}' failed with output:")
echo(output)
failTestSource(testSource)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
Expand Down
29 changes: 23 additions & 6 deletions compiler/test/dotty/tools/vulpix/SummaryReport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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`
Expand Down Expand Up @@ -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
}
}

Expand All @@ -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 {
Expand Down