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

SI-7696 Restore --show-log #63

Merged
merged 3 commits into from
Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 23 additions & 9 deletions src/main/scala/scala/tools/partest/nest/NestUI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -171,6 +182,9 @@ object NestUI {
def setDiffOnFail() {
_diff = true
}
def setLogOnFail() {
_logging = true
}
def verbose(msg: String) {
if (isVerbose)
System.err.println(msg)
Expand Down
31 changes: 29 additions & 2 deletions src/main/scala/scala/tools/partest/nest/Runner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/scala/tools/partest/nest/RunnerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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" --?
Expand Down