@@ -39,13 +39,13 @@ object DPConsoleRunner {
39
39
40
40
// console runner has a suite runner which creates a test runner for each test
41
41
class DPConsoleRunner (args : String , extraJars : List [String ]) extends ConsoleRunner (args) {
42
- println(" ConsoleRunner options: " + args)
43
42
44
43
override val suiteRunner = new DPSuiteRunner (
45
44
testSourcePath = optSourcePath getOrElse DPConfig .testRoot,
46
45
fileManager = new DottyFileManager (extraJars),
47
46
updateCheck = optUpdateCheck,
48
- failed = optFailed)
47
+ failed = optFailed,
48
+ consoleArgs = args)
49
49
50
50
override def run = {}
51
51
def runPartest = super .run
@@ -62,6 +62,7 @@ class DPSuiteRunner(testSourcePath: String, // relative path, like "files", or "
62
62
fileManager : DottyFileManager ,
63
63
updateCheck : Boolean ,
64
64
failed : Boolean ,
65
+ consoleArgs : String ,
65
66
javaCmdPath : String = PartestDefaults .javaCmd,
66
67
javacCmdPath : String = PartestDefaults .javacCmd,
67
68
scalacExtraArgs : Seq [String ] = Seq .empty)
@@ -76,9 +77,11 @@ extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPat
76
77
override def banner : String = {
77
78
s """ |Welcome to Partest for Dotty! Partest version: ${Properties .versionNumberString}
78
79
|Compiler under test: dotty.tools.dotc.Bench or dotty.tools.dotc.Main
79
- |Test root : ${PathSettings .srcDir}${File .separator}
80
+ |Generated test sources : ${PathSettings .srcDir}${File .separator}
80
81
|Test directories: ${DPConfig .testDirs.toList.mkString(" , " )}
82
+ |Debugging: failed tests have compiler output in test-kind.clog, run output in test-kind.log, class files in test-kind.obj
81
83
|Parallel: ${DPConfig .runTestsInParallel}
84
+ |Options: (use partest --help for usage information) ${consoleArgs}
82
85
""" .stripMargin
83
86
}
84
87
@@ -92,12 +95,13 @@ extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPat
92
95
// Parts of test output might end up in the wrong file or get lost.
93
96
Console .out.flush
94
97
Console .err.flush
95
- val clog = SFile ( runner.logFile).changeExtension( " clog " )
98
+ val clog = runner.cLogFile
96
99
val stream = new PrintStream (new FileOutputStream (clog.jfile), true )
97
100
val result = Console .withOut(stream)({ Console .withErr(stream)({
98
- runner.run()
101
+ val res = runner.run()
99
102
Console .err.flush
100
103
Console .out.flush
104
+ res
101
105
})})
102
106
result match {
103
107
// Append compiler output to transcript if compilation failed,
@@ -117,6 +121,8 @@ extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPat
117
121
}
118
122
119
123
class DPTestRunner (testFile : File , suiteRunner : DPSuiteRunner ) extends nest.Runner (testFile, suiteRunner) {
124
+ val cLogFile = SFile (logFile).changeExtension(" clog" )
125
+
120
126
// override to provide DottyCompiler
121
127
override def newCompiler = new dotty.partest.DPDirectCompiler (this )
122
128
@@ -199,6 +205,38 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
199
205
}
200
206
}
201
207
208
+ // override to change check file updating to original file, not generated
209
+ override def diffIsOk : Boolean = {
210
+ // always normalize the log first
211
+ normalizeLog()
212
+ val diff = currentDiff
213
+ // if diff is not empty, is update needed?
214
+ val updating : Option [Boolean ] = (
215
+ if (diff == " " ) None
216
+ else Some (suiteRunner.updateCheck)
217
+ )
218
+ pushTranscript(s " diff $logFile $checkFile" )
219
+ nextTestAction(updating) {
220
+ case Some (true ) =>
221
+ val origCheck = SFile (checkFile.changeExtension(" checksrc" ).fileLines(1 ))
222
+ NestUI .echo(" Updating original checkfile " + origCheck)
223
+ origCheck writeAll file2String(logFile)
224
+ genUpdated()
225
+ case Some (false ) =>
226
+ // Get a word-highlighted diff from git if we can find it
227
+ val bestDiff = if (updating.isEmpty) " " else {
228
+ if (checkFile.canRead)
229
+ gitDiff(logFile, checkFile) getOrElse {
230
+ s " diff $logFile $checkFile\n $diff"
231
+ }
232
+ else diff
233
+ }
234
+ pushTranscript(bestDiff)
235
+ genFail(" output differs" )
236
+ case None => genPass() // redundant default case
237
+ } getOrElse true
238
+ }
239
+
202
240
// override because Dotty currently doesn't handle separate compilation well,
203
241
// so we ignore groups (tests suffixed with _1 and _2)
204
242
override def groupedFiles (sources : List [File ]): List [List [File ]] = {
@@ -223,4 +261,10 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
223
261
// override to add dotty and scala jars to classpath
224
262
override def extraClasspath = suiteRunner.fileManager.asInstanceOf [DottyFileManager ].extraJarList ::: super .extraClasspath
225
263
264
+ // override to keep class files if failed and delete clog if ok
265
+ override def cleanup = if (lastState.isOk) {
266
+ logFile.delete
267
+ cLogFile.delete
268
+ Directory (outDir).deleteRecursively
269
+ }
226
270
}
0 commit comments