diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2017-04-13 10:09:37 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2017-04-13 11:02:30 +0200 |
commit | 7e33bc4c11ffc5e6ecc6fb7bcbfd54c497db2c02 (patch) | |
tree | c62f158dc9187c4c95834a6617af05d81f475358 /compiler/test/dotty/tools | |
parent | c9e1bc5b6324d2a896d731eeec32bdd941d1629b (diff) | |
download | dotty-7e33bc4c11ffc5e6ecc6fb7bcbfd54c497db2c02.tar.gz dotty-7e33bc4c11ffc5e6ecc6fb7bcbfd54c497db2c02.tar.bz2 dotty-7e33bc4c11ffc5e6ecc6fb7bcbfd54c497db2c02.zip |
Fix #2242: let user know which file got logged to
Diffstat (limited to 'compiler/test/dotty/tools')
-rw-r--r-- | compiler/test/dotty/tools/dotc/reporting/TestReporter.scala | 28 | ||||
-rw-r--r-- | compiler/test/dotty/tools/vulpix/SummaryReport.scala | 11 |
2 files changed, 29 insertions, 10 deletions
diff --git a/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala b/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala index 7952ed728..213181b56 100644 --- a/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala +++ b/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala @@ -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() = { diff --git a/compiler/test/dotty/tools/vulpix/SummaryReport.scala b/compiler/test/dotty/tools/vulpix/SummaryReport.scala index efca94bba..81da634f7 100644 --- a/compiler/test/dotty/tools/vulpix/SummaryReport.scala +++ b/compiler/test/dotty/tools/vulpix/SummaryReport.scala @@ -102,10 +102,11 @@ final class SummaryReport extends SummaryReporting { 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,7 +117,7 @@ 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()) |