This repository was archived by the owner on Sep 8, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +54
-11
lines changed
src/main/scala/scala/tools/partest/nest Expand file tree Collapse file tree 4 files changed +54
-11
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ abstract class AbstractRunner(argstr: String) extends {
94
94
if (optVerbose) NestUI .setVerbose()
95
95
if (optTerse) NestUI .setTerse()
96
96
if (optShowDiff) NestUI .setDiffOnFail()
97
+ if (optShowLog) NestUI .setLogOnFail()
97
98
98
99
// Early return on no args, version, or invalid args
99
100
if (optVersion) return echo(versionMsg)
Original file line number Diff line number Diff line change @@ -73,25 +73,34 @@ object NestUI {
73
73
f " $word $testNumber - $testIdent%-40s $reasonString"
74
74
}
75
75
76
- def reportTest (state : TestState ) = {
76
+ def reportTest (state : TestState , info : TestInfo ) =
77
77
if (isTerse && state.isOk) {
78
78
if (dotCount >= DotWidth ) {
79
79
outline(" \n ." )
80
80
dotCount = 1
81
- }
82
- else {
81
+ } else {
83
82
outline(" ." )
84
83
dotCount += 1
85
84
}
86
- }
87
- else {
85
+ } else {
88
86
echo(statusLine(state))
89
- if (! state.isOk && isDiffy) {
90
- val differ = bold(red(" % " )) + " diff "
91
- state.transcript find (_ startsWith differ) foreach (echo(_))
87
+ 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
+ }
92
+ if (isDiffy) {
93
+ val differ = bold(red(" % " )) + " diff "
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 _ => ()
99
+ }
100
+ }
101
+ if (isLogging) showLog()
92
102
}
93
103
}
94
- }
95
104
96
105
def echo (message : String ): Unit = synchronized {
97
106
leftFlush()
@@ -153,11 +162,13 @@ object NestUI {
153
162
var _debug = false
154
163
var _terse = false
155
164
var _diff = false
165
+ var _logging = false
156
166
157
167
def isVerbose = _verbose
158
168
def isDebug = _debug
159
169
def isTerse = _terse
160
170
def isDiffy = _diff
171
+ def isLogging = _logging
161
172
162
173
def setVerbose () {
163
174
_verbose = true
@@ -171,6 +182,9 @@ object NestUI {
171
182
def setDiffOnFail () {
172
183
_diff = true
173
184
}
185
+ def setLogOnFail () {
186
+ _logging = true
187
+ }
174
188
def verbose (msg : String ) {
175
189
if (isVerbose)
176
190
System .err.println(msg)
Original file line number Diff line number Diff line change @@ -42,8 +42,35 @@ class TestTranscript {
42
42
}
43
43
}
44
44
45
+ trait TestInfo {
46
+ /** pos/t1234 */
47
+ def testIdent : String
48
+
49
+ /** pos */
50
+ def kind : String
51
+
52
+ // inputs
53
+
54
+ /** pos/t1234.scala or pos/t1234 if dir */
55
+ def testFile : File
56
+
57
+ /** pos/t1234.check */
58
+ def checkFile : File
59
+
60
+ /** pos/t1234.flags */
61
+ def flagsFile : File
62
+
63
+ // outputs
64
+
65
+ /** pos/t1234-pos.obj */
66
+ def outFile : File
67
+
68
+ /** pos/t1234-pos.log */
69
+ def logFile : File
70
+ }
71
+
45
72
/** Run a single test. Rubber meets road. */
46
- class Runner (val testFile : File , val suiteRunner : SuiteRunner ) {
73
+ class Runner (val testFile : File , val suiteRunner : SuiteRunner ) extends TestInfo {
47
74
48
75
import suiteRunner .{fileManager => fm , _ }
49
76
val fileManager = fm
@@ -810,7 +837,7 @@ class SuiteRunner(
810
837
catch {
811
838
case t : Throwable => throw new RuntimeException (s " Error running $testFile" , t)
812
839
}
813
- NestUI .reportTest(state)
840
+ NestUI .reportTest(state, runner )
814
841
runner.cleanup()
815
842
state
816
843
}
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ trait RunnerSpec extends Spec with Meta.StdOpts with Interpolation {
36
36
37
37
heading(" Test output options:" )
38
38
val optShowDiff = " show-diff" / " show diffs for failed tests" --?
39
+ val optShowLog = " show-log" / " show log files for failed tests" --?
39
40
val optVerbose = " verbose" / " show verbose progress information" --?
40
41
val optTerse = " terse" / " show terse progress information" --?
41
42
val optDebug = " debug" / " enable debugging output" --?
You can’t perform that action at this time.
0 commit comments