Skip to content

Commit b9c3f96

Browse files
committed
Fix --show-diff for partest
1 parent 2bfbb8e commit b9c3f96

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

test/dotty/partest/DPConsoleRunner.scala

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,30 @@ extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPat
113113
} catch {
114114
case t: Throwable => throw new RuntimeException(s"Error running $testFile", t)
115115
}
116-
NestUI.reportTest(state)
116+
reportTest(state)
117117
runner.cleanup()
118118

119119
onFinishTest(testFile, state)
120120
}
121+
122+
// override NestUI.reportTest because --show-diff doesn't work. The diff used
123+
// seems to add each line to transcript separately, whereas NestUI assumes
124+
// that the diff string was added as one entry in the transcript
125+
def reportTest(state: TestState) = {
126+
import NestUI._
127+
import NestUI.color._
128+
129+
if (isTerse && state.isOk) {
130+
NestUI.reportTest(state)
131+
} else {
132+
echo(statusLine(state))
133+
if (!state.isOk && isDiffy) {
134+
val differ = bold(red("% ")) + "diff "
135+
state.transcript.dropWhile(s => !(s startsWith differ)) foreach (echo(_))
136+
// state.transcript find (_ startsWith differ) foreach (echo(_)) // original
137+
}
138+
}
139+
}
121140
}
122141

123142
class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runner(testFile, suiteRunner) {

0 commit comments

Comments
 (0)