Skip to content
This repository was archived by the owner on Sep 8, 2022. It is now read-only.

Commit f443386

Browse files
committed
SI-7696 --show-diff shows log on crash
If a test throws (and exits non-zero), you can see the log with `--verbose` (which shows the whole transcript), `--show-log`, and now also `--show-diff` (which will show log if the other options aren't set, the test failed and there's no diff to view.
1 parent 2ff0930 commit f443386

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/main/scala/scala/tools/partest/nest/NestUI.scala

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ object NestUI {
7373
f"$word $testNumber - $testIdent%-40s$reasonString"
7474
}
7575

76-
def reportTest(state: TestState, info: TestInfo) = {
76+
def reportTest(state: TestState, info: TestInfo) =
7777
if (isTerse && state.isOk) {
7878
if (dotCount >= DotWidth) {
7979
outline("\n.")
@@ -85,20 +85,22 @@ object NestUI {
8585
} else {
8686
echo(statusLine(state))
8787
if (!state.isOk) {
88+
def showLog() = if (info.logFile.canRead) {
89+
echo(bold(cyan(s"##### Log file '${info.logFile}' from failed test #####\n")))
90+
echo(info.logFile.fileContents)
91+
}
8892
if (isDiffy) {
8993
val differ = bold(red("% ")) + "diff "
90-
state.transcript find (_ startsWith differ) foreach (echo(_))
91-
}
92-
if (isLogging) {
93-
def log(f: File) = {
94-
echo(bold(cyan(s"##### Log file '$f' from failed test #####\n")))
95-
echo(f.fileContents)
94+
val diffed = state.transcript find (_ startsWith differ)
95+
diffed match {
96+
case Some(diff) => echo(diff)
97+
case None if !isLogging && !isPartestVerbose => showLog()
98+
case _ => ()
9699
}
97-
if (info.logFile.canRead) log(info.logFile)
98100
}
101+
if (isLogging) showLog()
99102
}
100103
}
101-
}
102104

103105
def echo(message: String): Unit = synchronized {
104106
leftFlush()

0 commit comments

Comments
 (0)