Skip to content
Open
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
50 changes: 32 additions & 18 deletions compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import dotty.tools.vulpix.TestConfiguration.defaultOptions
* using this, you should be running your JUnit tests **sequentially**, as the
* test suite itself runs with a high level of concurrency.
*/
trait ParallelTesting extends RunnerOrchestration { self =>
import ParallelTesting._
trait ParallelTesting extends RunnerOrchestration:
import ParallelTesting.*

/** If the running environment supports an interactive terminal, each `Test`
* will be run with a progress bar and real time feedback
Expand Down Expand Up @@ -935,29 +935,33 @@ trait ParallelTesting extends RunnerOrchestration { self =>
(errorMap, expectedErrors)
end getErrorMapAndExpectedCount

// return unfulfilled expected errors and unexpected diagnostics
// return unfulfilled expected errors and unexpected diagnostics.
// the errorMap of expected errors is drained and returned as unfulfilled.
// a diagnostic at EOF after NL is recorded at the preceding line,
// to obviate `anypos-error` in that case.
def getMissingExpectedErrors(errorMap: HashMap[String, Integer], reporterErrors: Iterator[Diagnostic]): (List[String], List[String]) =
val unexpected, unpositioned = ListBuffer.empty[String]
// For some reason, absolute paths leak from the compiler itself...
def relativize(path: String): String = path.split(JFile.separatorChar).dropWhile(_ != "tests").mkString(JFile.separator)
def seenAt(key: String): Boolean =
errorMap.get(key) match
case null => false
case 1 => errorMap.remove(key); true
case n => errorMap.put(key, n - 1); true
case null => false
case 1 => errorMap.remove(key); true
case n => errorMap.put(key, n - 1); true
def sawDiagnostic(d: Diagnostic): Unit =
d.pos.nonInlined match
case srcpos if srcpos.exists =>
val key = s"${relativize(srcpos.source.file.toString)}:${srcpos.line + 1}"
if !seenAt(key) then unexpected += key
case srcpos =>
if !seenAt("nopos") then unpositioned += relativize(srcpos.source.file.toString)
val srcpos = d.pos.nonInlined.adjustedAtEOF
val relatively = relativize(srcpos.source.file.toString)
if srcpos.exists then
val key = s"${relatively}:${srcpos.line + 1}"
if !seenAt(key) then unexpected += key
else
if !seenAt("nopos") then unpositioned += relatively

reporterErrors.foreach(sawDiagnostic)

errorMap.get("anypos") match
case n if n == unexpected.size => errorMap.remove("anypos") ; unexpected.clear()
case _ =>
if errorMap.get("anypos") == unexpected.size then
errorMap.remove("anypos")
unexpected.clear()

(errorMap.asScala.keys.toList, (unexpected ++ unpositioned).toList)
end getMissingExpectedErrors
Expand Down Expand Up @@ -1570,9 +1574,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
flags.options.sliding(2).collectFirst {
case Array("-encoding", encoding) => Charset.forName(encoding)
}.getOrElse(StandardCharsets.UTF_8)
}

object ParallelTesting {

object ParallelTesting:

def defaultOutputDir: String = "out"+JFile.separator

Expand All @@ -1584,4 +1588,14 @@ object ParallelTesting {
def isTastyFile(f: JFile): Boolean =
f.getName.endsWith(".tasty")

}
extension (pos: SourcePosition)
private def adjustedAtEOF: SourcePosition =
if pos.span.isSynthetic
&& pos.span.isZeroExtent
&& pos.span.exists
&& pos.span.start == pos.source.length
&& pos.source(pos.span.start - 1) == '\n'
then
pos.withSpan(pos.span.shift(-1))
else
pos
2 changes: 1 addition & 1 deletion tests/neg/parser-stability-11.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ case class x0 // error // error
}
package x0
class x0 // error
// error
// error
Loading