@@ -504,11 +504,19 @@ trait ParallelTesting extends RunnerOrchestration { self =>
504
504
reporter
505
505
}
506
506
507
- private def parseErrors (errorsText : String , compilerVersion : String ) =
507
+ private def parseErrors (errorsText : String , compilerVersion : String , pageWidth : Int ) =
508
508
val errorPattern = """ ^.*Error: (.*\.scala):(\d+):(\d+).*""" .r
509
509
val summaryPattern = """ \d+ (?:warning|error)s? found""" .r
510
510
val indent = " "
511
511
var diagnostics = List .empty[Diagnostic .Error ]
512
+ def barLine (start : Boolean ) = s " $indent${if start then " ╭" else " ╰" }${" ┄" * pageWidth}${if start then " ╮" else " ╯" }\n "
513
+ def errorLine (line : String ) = s " $indent┆ ${String .format(s " %- ${pageWidth}s " , stripAnsi(line))}┆ \n "
514
+ def stripAnsi (str : String ): String = str.replaceAll(" \u001b\\ [\\ d+m" , " " )
515
+ def addToLast (str : String ): Unit =
516
+ diagnostics match
517
+ case head :: tail =>
518
+ diagnostics = Diagnostic .Error (s " ${head.msg.rawMessage}$str" , head.pos) :: tail
519
+ case Nil =>
512
520
for line <- errorsText.linesIterator do
513
521
line match
514
522
case error @ errorPattern(filePath, line, column) =>
@@ -519,13 +527,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
519
527
val offset = sourceFile.lineToOffset(lineNum - 1 ) + columnNum - 1
520
528
val span = Spans .Span (offset)
521
529
val sourcePos = SourcePosition (sourceFile, span)
522
- diagnostics ::= Diagnostic .Error (s " Compilation of $filePath with Scala $compilerVersion failed at line: $line, column: $column. Full error output: \n\n $indent$error\n " , sourcePos)
530
+ addToLast(barLine(start = false ))
531
+ diagnostics ::= Diagnostic .Error (s " Compilation of $filePath with Scala $compilerVersion failed at line: $line, column: $column. \n Full error output: \n ${barLine(start = true )}${errorLine(error)}" , sourcePos)
523
532
case summaryPattern() => // Ignored
524
- case errorLine =>
525
- diagnostics match
526
- case head :: tail =>
527
- diagnostics = Diagnostic .Error (s " ${head.msg.rawMessage}$indent$errorLine\n " , head.pos) :: tail
528
- case Nil =>
533
+ case line => addToLast(errorLine(line))
534
+ addToLast(barLine(start = false ))
529
535
diagnostics.reverse
530
536
531
537
protected def compileWithOtherCompiler (compiler : String , files : Array [JFile ], flags : TestFlags , targetDir : JFile ): TestReporter =
@@ -537,18 +543,19 @@ trait ParallelTesting extends RunnerOrchestration { self =>
537
543
else o
538
544
}.mkString(JFile .pathSeparator)
539
545
546
+ val pageWidth = 80
540
547
val flags1 = flags.copy(defaultClassPath = substituteClasspath(flags.defaultClassPath))
541
548
.withClasspath(targetDir.getPath)
542
549
.and(" -d" , targetDir.getPath)
543
- .and(" -pagewidth" , " 80 " )
550
+ .and(" -pagewidth" , pageWidth.toString )
544
551
545
552
val reporter = TestReporter .reporter(System .out, ERROR )
546
553
547
554
val command = Array (compilerDir + " /bin/scalac" ) ++ flags1.all ++ files.map(_.getPath)
548
555
val process = Runtime .getRuntime.exec(command)
549
556
val errorsText = Source .fromInputStream(process.getErrorStream).mkString
550
557
if process.waitFor() != 0 then
551
- val diagnostics = parseErrors(errorsText, compiler)
558
+ val diagnostics = parseErrors(errorsText, compiler, pageWidth )
552
559
diagnostics.foreach { diag =>
553
560
val context = (new ContextBase ).initialCtx
554
561
reporter.report(diag)(using context)
0 commit comments