diff --git a/src/main/scala/scala/tools/partest/nest/AbstractRunner.scala b/src/main/scala/scala/tools/partest/nest/AbstractRunner.scala index bfc364f..d26413c 100644 --- a/src/main/scala/scala/tools/partest/nest/AbstractRunner.scala +++ b/src/main/scala/scala/tools/partest/nest/AbstractRunner.scala @@ -94,6 +94,7 @@ abstract class AbstractRunner(argstr: String) extends { if (optVerbose) NestUI.setVerbose() if (optTerse) NestUI.setTerse() if (optShowDiff) NestUI.setDiffOnFail() + if (optShowLog) NestUI.setLogOnFail() // Early return on no args, version, or invalid args if (optVersion) return echo(versionMsg) diff --git a/src/main/scala/scala/tools/partest/nest/NestUI.scala b/src/main/scala/scala/tools/partest/nest/NestUI.scala index a22351e..e70f4e9 100644 --- a/src/main/scala/scala/tools/partest/nest/NestUI.scala +++ b/src/main/scala/scala/tools/partest/nest/NestUI.scala @@ -73,25 +73,34 @@ object NestUI { f"$word $testNumber - $testIdent%-40s$reasonString" } - def reportTest(state: TestState) = { + def reportTest(state: TestState, info: TestInfo) = if (isTerse && state.isOk) { if (dotCount >= DotWidth) { outline("\n.") dotCount = 1 - } - else { + } else { outline(".") dotCount += 1 } - } - else { + } else { echo(statusLine(state)) - if (!state.isOk && isDiffy) { - val differ = bold(red("% ")) + "diff " - state.transcript find (_ startsWith differ) foreach (echo(_)) + if (!state.isOk) { + def showLog() = if (info.logFile.canRead) { + echo(bold(cyan(s"##### Log file '${info.logFile}' from failed test #####\n"))) + echo(info.logFile.fileContents) + } + if (isDiffy) { + val differ = bold(red("% ")) + "diff " + val diffed = state.transcript find (_ startsWith differ) + diffed match { + case Some(diff) => echo(diff) + case None if !isLogging && !isPartestVerbose => showLog() + case _ => () + } + } + if (isLogging) showLog() } } - } def echo(message: String): Unit = synchronized { leftFlush() @@ -153,11 +162,13 @@ object NestUI { var _debug = false var _terse = false var _diff = false + var _logging = false def isVerbose = _verbose def isDebug = _debug def isTerse = _terse def isDiffy = _diff + def isLogging = _logging def setVerbose() { _verbose = true @@ -171,6 +182,9 @@ object NestUI { def setDiffOnFail() { _diff = true } + def setLogOnFail() { + _logging = true + } def verbose(msg: String) { if (isVerbose) System.err.println(msg) diff --git a/src/main/scala/scala/tools/partest/nest/Runner.scala b/src/main/scala/scala/tools/partest/nest/Runner.scala index d83a931..7a54ef0 100644 --- a/src/main/scala/scala/tools/partest/nest/Runner.scala +++ b/src/main/scala/scala/tools/partest/nest/Runner.scala @@ -42,8 +42,35 @@ class TestTranscript { } } +trait TestInfo { + /** pos/t1234 */ + def testIdent: String + + /** pos */ + def kind: String + + // inputs + + /** pos/t1234.scala or pos/t1234 if dir */ + def testFile: File + + /** pos/t1234.check */ + def checkFile: File + + /** pos/t1234.flags */ + def flagsFile: File + + // outputs + + /** pos/t1234-pos.obj */ + def outFile: File + + /** pos/t1234-pos.log */ + def logFile: File +} + /** Run a single test. Rubber meets road. */ -class Runner(val testFile: File, val suiteRunner: SuiteRunner) { +class Runner(val testFile: File, val suiteRunner: SuiteRunner) extends TestInfo { import suiteRunner.{fileManager => fm, _} val fileManager = fm @@ -802,7 +829,7 @@ class SuiteRunner( catch { case t: Throwable => throw new RuntimeException(s"Error running $testFile", t) } - NestUI.reportTest(state) + NestUI.reportTest(state, runner) runner.cleanup() state } diff --git a/src/main/scala/scala/tools/partest/nest/RunnerSpec.scala b/src/main/scala/scala/tools/partest/nest/RunnerSpec.scala index 46d0088..974a5e9 100644 --- a/src/main/scala/scala/tools/partest/nest/RunnerSpec.scala +++ b/src/main/scala/scala/tools/partest/nest/RunnerSpec.scala @@ -36,6 +36,7 @@ trait RunnerSpec extends Spec with Meta.StdOpts with Interpolation { heading("Test output options:") val optShowDiff = "show-diff" / "show diffs for failed tests" --? + val optShowLog = "show-log" / "show log files for failed tests" --? val optVerbose = "verbose" / "show verbose progress information" --? val optTerse = "terse" / "show terse progress information" --? val optDebug = "debug" / "enable debugging output" --?