Skip to content
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
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/report.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ object report:
case Nil => pos
recur(pos.sourcePos, tpd.enclosingInlineds)

private object messageRendering extends MessageRendering

// Should only be called from Run#enrichErrorMessage.
def enrichErrorMessage(errorMessage: String)(using Context): String =
if ctx.settings.YnoEnrichErrorMessages.value then errorMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import java.lang.System.{lineSeparator => EOL}

import core.Contexts.*
import core.Decorators.*
import io.AbstractFile
import printing.Highlighting.{Blue, Red, Yellow}
import printing.SyntaxHighlighting
import Diagnostic.*
Expand Down Expand Up @@ -158,9 +159,12 @@ trait MessageRendering {
.mkString(EOL)
}

// file.path or munge it to normalize for testing
protected def renderPath(file: AbstractFile): String = file.path

/** The source file path, line and column numbers from the given SourcePosition */
protected def posFileStr(pos: SourcePosition): String =
val path = pos.source.file.path
val path = renderPath(pos.source.file)
if pos.exists then s"$path:${pos.line + 1}:${pos.column}" else path

/** The separator between errors containing the source file and error type
Expand Down
27 changes: 22 additions & 5 deletions compiler/test/dotty/tools/dotc/reporting/TestReporter.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package dotty.tools
package dotty
package tools
package dotc
package reporting

import scala.language.unsafeNulls
import java.io.{BufferedReader, FileInputStream, FileOutputStream, FileReader, PrintStream, PrintWriter, StringReader, StringWriter, File as JFile}
import java.io.{File as JFile, *}
import java.nio.file.Files.readAllLines
import java.text.SimpleDateFormat
import java.util.Date

import core.Contexts.*
import core.Decorators.*
import interfaces.Diagnostic.{ERROR, WARNING}
import io.AbstractFile
import util.SourcePosition
import Diagnostic.*

import scala.collection.mutable
import scala.jdk.CollectionConverters.*
Expand All @@ -29,13 +36,17 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
final def messages: Iterator[String] = _messageBuf.iterator

protected final val _consoleBuf = new StringWriter
protected final val _consoleReporter = new ConsoleReporter(null, new PrintWriter(_consoleBuf))
protected final val _consoleReporter = new ConsoleReporter(null, new PrintWriter(_consoleBuf)):
override protected def renderPath(file: AbstractFile): String = TestReporter.renderPath(file)

final def consoleOutput: String = _consoleBuf.toString

private var _skip: Boolean = false
final def setSkip(): Unit = _skip = true
final def skipped: Boolean = _skip

override protected def renderPath(file: AbstractFile): String = TestReporter.renderPath(file)

protected final def inlineInfo(pos: SourcePosition)(using Context): String =
if (pos.exists) {
if (pos.outer.exists)
Expand Down Expand Up @@ -149,10 +160,16 @@ object TestReporter {
Properties.rerunFailed &&
failedTestsFile.exists() &&
failedTestsFile.isFile
)(java.nio.file.Files.readAllLines(failedTestsFile.toPath).asScala.toList)
)(readAllLines(failedTestsFile.toPath).asScala.toList)

def writeFailedTests(tests: List[String]): Unit =
initLog()
tests.foreach(failed => failedTestsWriter.println(failed))
failedTestsWriter.flush()

def renderPath(file: AbstractFile): String =
if JFile.separatorChar == '\\' then
file.path.replace('\\', '/')
else
file.path
}
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ trait ParallelTesting extends RunnerOrchestration:
checkFile(testSource).foreach(diffTest(testSource, _, reporterOutputLines(reporters), reporters, logger))

private def reporterOutputLines(reporters: Seq[TestReporter]): List[String] =
reporters.flatMap(_.consoleOutput.split("\n")).toList
reporters.flatMap(_.consoleOutput.linesIterator).toList

private[ParallelTesting] def executeTestSuite(): this.type = {
assert(testSourcesCompleted == 0, "not allowed to re-use a `CompileRun`")
Expand Down
1 change: 0 additions & 1 deletion tests/neg-custom-args/captures/cc-this2.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-custom-args/captures/cc-this2/D_2.scala:2:6 --------------------------------------------------------
2 |class D extends C: // error
|^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/annot-crash.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/annot-crash/Test_2.scala:1:0 ----------------------------------------------------------------
1 |@crash // error
|^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/annot-empty-result.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/annot-empty-result/Test_2.scala:5:2 ---------------------------------------------------------
5 | @nilAnnot // error
| ^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/annot-error-annot.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/annot-error-annot/Test_2.scala:17:6 ---------------------------------------------------------
16 |@error
17 |class cGlobal // error
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/annot-ill-abort.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/annot-ill-abort/Test_2.scala:1:0 ------------------------------------------------------------
1 |@crash // error
|^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/annot-mod-class-add-top-method.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/annot-mod-class-add-top-method/Test_2.scala:1:0 ---------------------------------------------
1 |@addTopLevelMethod // error
|^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/annot-mod-class-add-top-val.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/annot-mod-class-add-top-val/Test_2.scala:1:0 ------------------------------------------------
1 |@addTopLevelVal // error
|^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/annot-on-type.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/annot-on-type/Test_2.scala:6:7 --------------------------------------------------------------
5 | @voidAnnot
6 | type C // error
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/annot-result-owner.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/annot-result-owner/Test_2.scala:1:0 ---------------------------------------------------------
1 |@insertVal // error
|^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/beta-reduce-inline-result.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- [E007] Type Mismatch Error: tests/neg-macros/beta-reduce-inline-result/Test_2.scala:11:41 ---------------------------
11 | val x2: 4 = Macros.betaReduce(dummy1)(3) // error
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/delegate-match-1.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/delegate-match-1/Test_2.scala:6:2 -----------------------------------------------------------
6 | f // error
| ^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/delegate-match-2.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/delegate-match-2/Test_2.scala:5:2 -----------------------------------------------------------
5 | f // error
| ^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/delegate-match-3.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/delegate-match-3/Test_2.scala:3:2 -----------------------------------------------------------
3 | f // error
| ^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i11386.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i11386/Test_2.scala:6:10 --------------------------------------------------------------------
6 | dummy(0) // error
| ^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i13991.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i13991/Test_2.scala:6:5 ---------------------------------------------------------------------
6 | v2 // error
| ^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i16582.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i16582/Test_2.scala:6:27 --------------------------------------------------------------------
6 | val o2 = ownerDoesNotWork(2) // error
| ^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i16835.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i16835/Test_2.scala:1:17 --------------------------------------------------------------------
1 |def test: Unit = foo // error
| ^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i18113.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i18113/Test_2.scala:7:8 ---------------------------------------------------------------------
7 | X.test(ref) // error
| ^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i18113b.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i18113b/Test_2.scala:7:8 --------------------------------------------------------------------
7 | X.test(ref) // error
| ^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i21916.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i21916/Test_2.scala:3:27 --------------------------------------------------------------------
3 |@main def Test = Macro.test() // error
| ^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i23008.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i23008/Test_2.scala:1:24 --------------------------------------------------------------------
1 |@main def Test = Macros.buildString // error
| ^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i6432.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i6432/Test_2.scala:4:6 ----------------------------------------------------------------------
4 | foo"abc${"123"}xyz${"456"}fgh" // error // error // error
| ^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i6432b.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i6432b/Test_2.scala:4:8 ---------------------------------------------------------------------
4 | foo"""abc${"123"}xyz${"456"}fgh""" // error // error // error
| ^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i6976.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i6976/Test_2.scala:5:44 ---------------------------------------------------------------------
5 | def main(args: Array[String]): Unit = mcr { 2 } // error
| ^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i9014.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/i9014/Test_2.scala:1:23 ---------------------------------------------------------------------
1 |val tests = summon[Bar] // error
| ^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i9014b.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- [E172] Type Error: tests/neg-macros/i9014b/Test_2.scala:1:23 --------------------------------------------------------
1 |val tests = summon[Bar] // error
| ^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/i9685.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- [E008] Not Found Error: tests/neg-macros/i9685/Test_2.scala:3:4 -----------------------------------------------------
3 | 1.asdf // error
| ^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg-macros/ill-abort.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg-macros/ill-abort/quoted_2.scala:1:15 ---------------------------------------------------------------
1 |def test = fail() // error
| ^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg/i20245.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- [E046] Cyclic Error: tests/neg/i20245/Typer_2.scala:16:57 -----------------------------------------------------------
16 | private[typer] val unification = new Unification(using this) // error
| ^
Expand Down
1 change: 0 additions & 1 deletion tests/neg/i9408b.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Error: tests/neg/i9408b/Test_2.scala:8:20 ---------------------------------------------------------------------------
8 | val length: Int = "abc" // error
| ^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg/mixin-forwarder-clash2.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- [E120] Naming Error: tests/neg/mixin-forwarder-clash2/B_2.scala:1:6 -------------------------------------------------
1 |class Bar2 extends Bar1 with Two[Foo] // error
| ^
Expand Down
1 change: 0 additions & 1 deletion tests/neg/yimports-custom.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- [E006] Not Found Error: tests/neg/yimports-custom/C_2.scala:5:16 ----------------------------------------------------
5 | def greet() = println("hello, world!") // error
| ^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/neg/yimports-stable.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

error: bad preamble import hello.world.potions
-- [E006] Not Found Error: tests/neg/yimports-stable/C_2.scala:4:9 -----------------------------------------------------
4 | val v: Numb = magic // error // error
Expand Down
1 change: 0 additions & 1 deletion tests/warn/i22795.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

-- Deprecation Warning: tests/warn/i22795/test_1.scala:4:7 -------------------------------------------------------------
4 | lib.m() // warn
| ^^^^^^^
Expand Down