Skip to content

Commit e8b695d

Browse files
committed
Add docs to SummaryReport.scala
1 parent 5dc83b0 commit e8b695d

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

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

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,38 @@ package vulpix
55
import scala.collection.mutable
66
import dotc.reporting.TestReporter
77

8+
/** `SummaryReporting` can be used by unit tests by utilizing `@AfterClass` to
9+
* call `echoSummary`
10+
*
11+
* This is used in vulpix by passing the companion object's `SummaryReporting`
12+
* to each test, the `@AfterClass def` then calls the `SummaryReport`'s
13+
* `echoSummary` method in order to dump the summary to both stdout and a log
14+
* file
15+
*/
816
trait SummaryReporting {
17+
/** Report a failed test */
918
def reportFailed(): Unit
19+
20+
/** Report a test as passing */
1021
def reportPassed(): Unit
22+
23+
/** Add the name of the failed test */
1124
def addFailedTest(msg: String): Unit
25+
26+
/** Add instructions to reproduce the error */
1227
def addReproduceInstruction(instr: String): Unit
28+
29+
/** Add a message that will be issued in the beginning of the summary */
1330
def addStartingMessage(msg: String): Unit
31+
32+
/** Add a cleanup hook to be run upon completion */
1433
def addCleanup(f: () => Unit): Unit
34+
35+
/** Echo the summary report to the appropriate locations */
1536
def echoSummary(): Unit
1637
}
1738

39+
/** A summary report that doesn't do anything */
1840
final class NoSummaryReport extends SummaryReporting {
1941
def reportFailed(): Unit = ()
2042
def reportPassed(): Unit = ()
@@ -25,6 +47,9 @@ final class NoSummaryReport extends SummaryReporting {
2547
def echoSummary(): Unit = ()
2648
}
2749

50+
/** A summary report that logs to both stdout and the `TestReporter.logWriter`
51+
* which outputs to a log file in `./testlogs/`
52+
*/
2853
final class SummaryReport extends SummaryReporting {
2954

3055
private val startingMessages = mutable.ArrayBuffer.empty[String]
@@ -72,8 +97,17 @@ final class SummaryReport extends SummaryReporting {
7297

7398
failedTests.map(x => " " + x).foreach(rep.append)
7499

75-
// If we're compiling locally, we don't need reproduce instructions
76-
if (isInteractive) println(rep.toString)
100+
// If we're compiling locally, we don't need instructions on how to
101+
// reproduce failures
102+
if (isInteractive) {
103+
println(rep.toString)
104+
println {
105+
"""|
106+
|----------------------------------------------------------
107+
|Note: reproduction instructed have been dumped to log file
108+
|----------------------------------------------------------""".stripMargin
109+
}
110+
}
77111

78112
rep += '\n'
79113

0 commit comments

Comments
 (0)