From b9c3f9624bd74c4f8bd5856ddbf86ccc52f21546 Mon Sep 17 00:00:00 2001 From: vsalvis Date: Wed, 27 May 2015 15:02:44 +0200 Subject: Fix --show-diff for partest --- test/dotty/partest/DPConsoleRunner.scala | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/dotty/partest/DPConsoleRunner.scala b/test/dotty/partest/DPConsoleRunner.scala index 788abe0e1..13ffed050 100644 --- a/test/dotty/partest/DPConsoleRunner.scala +++ b/test/dotty/partest/DPConsoleRunner.scala @@ -113,11 +113,30 @@ extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPat } catch { case t: Throwable => throw new RuntimeException(s"Error running $testFile", t) } - NestUI.reportTest(state) + reportTest(state) runner.cleanup() onFinishTest(testFile, state) } + + // override NestUI.reportTest because --show-diff doesn't work. The diff used + // seems to add each line to transcript separately, whereas NestUI assumes + // that the diff string was added as one entry in the transcript + def reportTest(state: TestState) = { + import NestUI._ + import NestUI.color._ + + if (isTerse && state.isOk) { + NestUI.reportTest(state) + } else { + echo(statusLine(state)) + if (!state.isOk && isDiffy) { + val differ = bold(red("% ")) + "diff " + state.transcript.dropWhile(s => !(s startsWith differ)) foreach (echo(_)) + // state.transcript find (_ startsWith differ) foreach (echo(_)) // original + } + } + } } class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runner(testFile, suiteRunner) { -- cgit v1.2.3