@@ -504,11 +504,19 @@ trait ParallelTesting extends RunnerOrchestration { self =>
504504 reporter
505505 }
506506
507- private def parseErrors (errorsText : String , compilerVersion : String ) =
507+ private def parseErrors (errorsText : String , compilerVersion : String , pageWidth : Int ) =
508508 val errorPattern = """ ^.*Error: (.*\.scala):(\d+):(\d+).*""" .r
509509 val summaryPattern = """ \d+ (?:warning|error)s? found""" .r
510510 val indent = " "
511511 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 =>
512520 for line <- errorsText.linesIterator do
513521 line match
514522 case error @ errorPattern(filePath, line, column) =>
@@ -519,13 +527,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
519527 val offset = sourceFile.lineToOffset(lineNum - 1 ) + columnNum - 1
520528 val span = Spans .Span (offset)
521529 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)
523532 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 ))
529535 diagnostics.reverse
530536
531537 protected def compileWithOtherCompiler (compiler : String , files : Array [JFile ], flags : TestFlags , targetDir : JFile ): TestReporter =
@@ -537,18 +543,19 @@ trait ParallelTesting extends RunnerOrchestration { self =>
537543 else o
538544 }.mkString(JFile .pathSeparator)
539545
546+ val pageWidth = 80
540547 val flags1 = flags.copy(defaultClassPath = substituteClasspath(flags.defaultClassPath))
541548 .withClasspath(targetDir.getPath)
542549 .and(" -d" , targetDir.getPath)
543- .and(" -pagewidth" , " 80 " )
550+ .and(" -pagewidth" , pageWidth.toString )
544551
545552 val reporter = TestReporter .reporter(System .out, ERROR )
546553
547554 val command = Array (compilerDir + " /bin/scalac" ) ++ flags1.all ++ files.map(_.getPath)
548555 val process = Runtime .getRuntime.exec(command)
549556 val errorsText = Source .fromInputStream(process.getErrorStream).mkString
550557 if process.waitFor() != 0 then
551- val diagnostics = parseErrors(errorsText, compiler)
558+ val diagnostics = parseErrors(errorsText, compiler, pageWidth )
552559 diagnostics.foreach { diag =>
553560 val context = (new ContextBase ).initialCtx
554561 reporter.report(diag)(using context)
0 commit comments