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

Commit 2ce9fc6

Browse files
committed
SI-7696 Restore --show-log
Look for the diff line in the transcript, which diffs the log file and the check file, to pick off the log file name, then just display the contents. For --show-diff output ``` \# starting 1 test in run !! 1 - run/foo.scala [output differs] % diff /home/apm/projects/snytt/test/files/run/foo-run.log /home/apm/projects/snytt/test/files/run/foo.check--- empty +++ foo-run.log @@ -1,0 +1,1 @@ +oops \# 0/1 passed, 1 failed in run ``` --show-log shows ``` \# starting 1 test in run !! 1 - run/foo.scala [output differs] \##### Log file '/home/apm/projects/snytt/test/files/run/foo-run.log' from failed test ##### oops \# 0/1 passed, 1 failed in run ``` where comment lines are prefixed by \ for purposes of commit message.
1 parent 53a5130 commit 2ce9fc6

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ abstract class AbstractRunner(argstr: String) extends {
9494
if (optVerbose) NestUI.setVerbose()
9595
if (optTerse) NestUI.setTerse()
9696
if (optShowDiff) NestUI.setDiffOnFail()
97+
if (optShowLog) NestUI.setLogOnFail()
9798

9899
// Early return on no args, version, or invalid args
99100
if (optVersion) return echo(versionMsg)

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,23 @@ object NestUI {
8686
}
8787
else {
8888
echo(statusLine(state))
89-
if (!state.isOk && isDiffy) {
90-
val differ = bold(red("% ")) + "diff "
91-
state.transcript find (_ startsWith differ) foreach (echo(_))
89+
if (!state.isOk) {
90+
if (isDiffy) {
91+
val differ = bold(red("% ")) + "diff "
92+
state.transcript find (_ startsWith differ) foreach (echo(_))
93+
}
94+
if (isLogging) {
95+
import scala.util.matching.Regex
96+
def log(f: File) = {
97+
echo(bold(cyan(s"##### Log file '$f' from failed test #####\n")))
98+
echo(f.fileContents)
99+
}
100+
val prompt = bold(red("% "))
101+
val differ = raw"(?s)${Regex.quote(prompt)}diff (\S*).*".r
102+
state.transcript.collect {
103+
case differ(f) => f
104+
} foreach (log(_))
105+
}
92106
}
93107
}
94108
}
@@ -153,11 +167,13 @@ object NestUI {
153167
var _debug = false
154168
var _terse = false
155169
var _diff = false
170+
var _logging = false
156171

157172
def isVerbose = _verbose
158173
def isDebug = _debug
159174
def isTerse = _terse
160175
def isDiffy = _diff
176+
def isLogging = _logging
161177

162178
def setVerbose() {
163179
_verbose = true
@@ -171,6 +187,9 @@ object NestUI {
171187
def setDiffOnFail() {
172188
_diff = true
173189
}
190+
def setLogOnFail() {
191+
_logging = true
192+
}
174193
def verbose(msg: String) {
175194
if (isVerbose)
176195
System.err.println(msg)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ trait RunnerSpec extends Spec with Meta.StdOpts with Interpolation {
3636

3737
heading("Test output options:")
3838
val optShowDiff = "show-diff" / "show diffs for failed tests" --?
39+
val optShowLog = "show-log" / "show log files for failed tests" --?
3940
val optVerbose = "verbose" / "show verbose progress information" --?
4041
val optTerse = "terse" / "show terse progress information" --?
4142
val optDebug = "debug" / "enable debugging output" --?

0 commit comments

Comments
 (0)