Skip to content

Commit 46e3395

Browse files
authored
Merge pull request #2248 from dotty-staging/topic/vulpix-fixes1
Various vulpix fixes
2 parents d1cbf5f + 3a15365 commit 46e3395

File tree

4 files changed

+56
-22
lines changed

4 files changed

+56
-22
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ class CompilationTests extends ParallelTesting {
216216
val opt = Array(
217217
"-classpath",
218218
// compile with bootstrapped library on cp:
219-
defaultOutputDir + "lib$1/src/:" +
219+
defaultOutputDir + "lib/src/:" +
220220
// as well as bootstrapped compiler:
221-
defaultOutputDir + "dotty1$1/dotty/:" +
221+
defaultOutputDir + "dotty1/dotty/:" +
222222
Jars.dottyInterfaces
223223
)
224224

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

+23-5
Original file line numberDiff line numberDiff line change
@@ -91,23 +91,41 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
9191
}
9292

9393
object TestReporter {
94-
val logWriter = {
94+
private[this] var outFile: JFile = _
95+
private[this] var logWriter: PrintWriter = _
96+
97+
private[this] def initLog() = if (logWriter eq null) {
9598
val df = new SimpleDateFormat("yyyy-MM-dd-HH:mm")
9699
val timestamp = df.format(new Date)
97100
new JFile("../testlogs").mkdirs()
98-
new PrintWriter(new FileOutputStream(new JFile(s"../testlogs/tests-$timestamp.log"), true))
101+
outFile = new JFile(s"../testlogs/tests-$timestamp.log")
102+
logWriter = new PrintWriter(new FileOutputStream(outFile, true))
99103
}
100104

101-
def writeToLog(str: String) = {
105+
def logPrintln(str: String) = {
106+
initLog()
102107
logWriter.println(str)
103108
logWriter.flush()
104109
}
105110

111+
def logPrint(str: String): Unit = {
112+
initLog()
113+
logWriter.println(str)
114+
}
115+
116+
def logFlush(): Unit =
117+
if (logWriter ne null) logWriter.flush()
118+
119+
def logPath: String = {
120+
initLog()
121+
outFile.getCanonicalPath
122+
}
123+
106124
def reporter(ps: PrintStream, logLevel: Int): TestReporter =
107-
new TestReporter(new PrintWriter(ps, true), writeToLog, logLevel)
125+
new TestReporter(new PrintWriter(ps, true), logPrintln, logLevel)
108126

109127
def simplifiedReporter(writer: PrintWriter): TestReporter = {
110-
val rep = new TestReporter(writer, writeToLog, WARNING) {
128+
val rep = new TestReporter(writer, logPrintln, WARNING) {
111129
/** Prints the message with the given position indication in a simplified manner */
112130
override def printMessageAndPos(m: MessageContainer, extra: String)(implicit ctx: Context): Unit = {
113131
def report() = {

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
192192

193193
/** A runnable that logs its contents in a buffer */
194194
trait LoggedRunnable extends Runnable {
195-
import TestReporter.logWriter
196-
197195
/** Instances of `LoggedRunnable` implement this method instead of the
198196
* `run` method
199197
*/
@@ -212,8 +210,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
212210

213211
final def run(): Unit = {
214212
checkTestSource()
215-
logBuffer.iterator.foreach(logWriter.println)
216-
logWriter.flush()
213+
summaryReport.echoToLog(logBuffer.iterator)
217214
}
218215
}
219216

@@ -265,7 +262,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
265262
private[this] val failedTestSources = mutable.ArrayBuffer.empty[String]
266263
protected final def failTestSource(testSource: TestSource, reason: Option[String] = None) = synchronized {
267264
val extra = reason.map(" with reason: " + _).getOrElse("")
268-
failedTestSources.append(testSource.title + s" failed (in ${testSource.name})" + extra)
265+
failedTestSources.append(testSource.title + s" failed" + extra)
269266
fail()
270267
}
271268

@@ -309,7 +306,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
309306
protected def tryCompile(testSource: TestSource)(op: => Unit): Unit =
310307
try {
311308
val testing = s"Testing ${testSource.title}"
312-
TestReporter.logWriter.println(testing)
309+
summaryReport.echoToLog(testing)
313310
if (!isInteractive) realStdout.println(testing)
314311
op
315312
} catch {
@@ -519,6 +516,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
519516
}
520517

521518
case Failure(output) =>
519+
echo(s"Test '${testSource.title}' failed with output:")
522520
echo(output)
523521
failTestSource(testSource)
524522

@@ -574,7 +572,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
574572

575573
if (!compilerCrashed && errorCount == 0) verifier()
576574
else {
577-
echo(s"\n Compilation failed for: '$testSource'")
575+
echo(s" Compilation failed for: '${testSource.title}' ")
578576
val buildInstr = testSource.buildInstructions(errorCount, warningCount)
579577
addFailureInstruction(buildInstr)
580578
failTestSource(testSource)
@@ -1018,6 +1016,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10181016
.getOrElse {
10191017
throw new IllegalStateException("Unable to reflectively find calling method")
10201018
}
1019+
.takeWhile(_ != '$')
10211020
}
10221021

10231022
/** Compiles a single file from the string path `f` using the supplied flags */
@@ -1072,7 +1071,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10721071
val targetDir = new JFile(outDir + "/" + sourceDir.getName + "/")
10731072
targetDir.mkdirs()
10741073

1075-
val target = JointCompilationSource(callingMethod, randomized, flags, targetDir)
1074+
val target = JointCompilationSource(s"compiling '$f' in test '$callingMethod'", randomized, flags, targetDir)
10761075
new CompilationTest(target)
10771076
}
10781077

@@ -1089,7 +1088,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10891088
targetDir.mkdirs()
10901089
assert(targetDir.exists, s"couldn't create target directory: $targetDir")
10911090

1092-
val target = JointCompilationSource(callingMethod, files.map(new JFile(_)).toArray, flags, targetDir)
1091+
val target = JointCompilationSource(s"$testName from $callingMethod", files.map(new JFile(_)).toArray, flags, targetDir)
10931092

10941093
// Create a CompilationTest and let the user decide whether to execute a pos or a neg test
10951094
new CompilationTest(target)

compiler/test/dotty/tools/vulpix/SummaryReport.scala

+23-6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ trait SummaryReporting {
3434

3535
/** Echo the summary report to the appropriate locations */
3636
def echoSummary(): Unit
37+
38+
/** Echoes *immediately* to file */
39+
def echoToLog(msg: String): Unit
40+
41+
/** Echoes contents of `it` to file *immediately* then flushes */
42+
def echoToLog(it: Iterator[String]): Unit
3743
}
3844

3945
/** A summary report that doesn't do anything */
@@ -45,6 +51,8 @@ final class NoSummaryReport extends SummaryReporting {
4551
def addStartingMessage(msg: String): Unit = ()
4652
def addCleanup(f: () => Unit): Unit = ()
4753
def echoSummary(): Unit = ()
54+
def echoToLog(msg: String): Unit = ()
55+
def echoToLog(it: Iterator[String]): Unit = ()
4856
}
4957

5058
/** A summary report that logs to both stdout and the `TestReporter.logWriter`
@@ -95,17 +103,18 @@ final class SummaryReport extends SummaryReporting {
95103

96104
startingMessages.foreach(rep.append)
97105

98-
failedTests.map(x => " " + x).foreach(rep.append)
106+
failedTests.map(x => s" $x\n").foreach(rep.append)
99107

100108
// If we're compiling locally, we don't need instructions on how to
101109
// reproduce failures
102110
if (isInteractive) {
103111
println(rep.toString)
104112
if (failed > 0) println {
105-
"""|
106-
|----------------------------------------------------------
107-
|Note: reproduction instructed have been dumped to log file
108-
|----------------------------------------------------------""".stripMargin
113+
s"""|
114+
|--------------------------------------------------------------------------------
115+
|Note - reproduction instructions have been dumped to log file:
116+
| ${TestReporter.logPath}
117+
|--------------------------------------------------------------------------------""".stripMargin
109118
}
110119
}
111120

@@ -116,11 +125,19 @@ final class SummaryReport extends SummaryReporting {
116125
// If we're on the CI, we want everything
117126
if (!isInteractive) println(rep.toString)
118127

119-
TestReporter.writeToLog(rep.toString)
128+
TestReporter.logPrintln(rep.toString)
120129

121130
// Perform cleanup callback:
122131
if (cleanUps.nonEmpty) cleanUps.foreach(_.apply())
123132
}
133+
134+
def echoToLog(msg: String): Unit =
135+
TestReporter.logPrintln(msg)
136+
137+
def echoToLog(it: Iterator[String]): Unit = {
138+
it.foreach(TestReporter.logPrint)
139+
TestReporter.logFlush()
140+
}
124141
}
125142

126143
object SummaryReport {

0 commit comments

Comments
 (0)