@@ -41,8 +41,8 @@ import dotty.tools.vulpix.TestConfiguration.defaultOptions
41
41
* using this, you should be running your JUnit tests **sequentially**, as the
42
42
* test suite itself runs with a high level of concurrency.
43
43
*/
44
- trait ParallelTesting extends RunnerOrchestration { self =>
45
- import ParallelTesting ._
44
+ trait ParallelTesting extends RunnerOrchestration :
45
+ import ParallelTesting .*
46
46
47
47
/** If the running environment supports an interactive terminal, each `Test`
48
48
* will be run with a progress bar and real time feedback
@@ -992,29 +992,33 @@ trait ParallelTesting extends RunnerOrchestration { self =>
992
992
(errorMap, expectedErrors)
993
993
end getErrorMapAndExpectedCount
994
994
995
- // return unfulfilled expected errors and unexpected diagnostics
995
+ // return unfulfilled expected errors and unexpected diagnostics.
996
+ // the errorMap of expected errors is drained and returned as unfulfilled.
997
+ // a diagnostic at EOF after NL is recorded at the preceding line,
998
+ // to obviate `anypos-error` in that case.
996
999
def getMissingExpectedErrors (errorMap : HashMap [String , Integer ], reporterErrors : Iterator [Diagnostic ]): (List [String ], List [String ]) =
997
1000
val unexpected, unpositioned = ListBuffer .empty[String ]
998
1001
// For some reason, absolute paths leak from the compiler itself...
999
1002
def relativize (path : String ): String = path.split(JFile .separatorChar).dropWhile(_ != " tests" ).mkString(JFile .separator)
1000
1003
def seenAt (key : String ): Boolean =
1001
1004
errorMap.get(key) match
1002
- case null => false
1003
- case 1 => errorMap.remove(key); true
1004
- case n => errorMap.put(key, n - 1 ); true
1005
+ case null => false
1006
+ case 1 => errorMap.remove(key); true
1007
+ case n => errorMap.put(key, n - 1 ); true
1005
1008
def sawDiagnostic (d : Diagnostic ): Unit =
1006
- d.pos.nonInlined match
1007
- case srcpos if srcpos.exists =>
1008
- val key = s " ${relativize(srcpos.source.file.toString)}: ${srcpos.line + 1 }"
1009
- if ! seenAt(key) then unexpected += key
1010
- case srcpos =>
1011
- if ! seenAt(" nopos" ) then unpositioned += relativize(srcpos.source.file.toString)
1009
+ val srcpos = d.pos.nonInlined.adjustedAtEOF
1010
+ val relatively = relativize(srcpos.source.file.toString)
1011
+ if srcpos.exists then
1012
+ val key = s " ${relatively}: ${srcpos.line + 1 }"
1013
+ if ! seenAt(key) then unexpected += key
1014
+ else
1015
+ if ! seenAt(" nopos" ) then unpositioned += relatively
1012
1016
1013
1017
reporterErrors.foreach(sawDiagnostic)
1014
1018
1015
- errorMap.get(" anypos" ) match
1016
- case n if n == unexpected.size => errorMap.remove(" anypos" ) ; unexpected.clear( )
1017
- case _ =>
1019
+ if errorMap.get(" anypos" ) == unexpected.size then
1020
+ errorMap.remove(" anypos" )
1021
+ unexpected.clear()
1018
1022
1019
1023
(errorMap.asScala.keys.toList, (unexpected ++ unpositioned).toList)
1020
1024
end getMissingExpectedErrors
@@ -1834,9 +1838,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1834
1838
def isUserDebugging : Boolean =
1835
1839
val mxBean = ManagementFactory .getRuntimeMXBean
1836
1840
mxBean.getInputArguments.asScala.exists(_.contains(" jdwp" ))
1837
- }
1838
1841
1839
- object ParallelTesting {
1842
+ object ParallelTesting :
1840
1843
1841
1844
def defaultOutputDir : String = " out" + JFile .separator
1842
1845
@@ -1851,4 +1854,14 @@ object ParallelTesting {
1851
1854
def isBestEffortTastyFile (f : JFile ): Boolean =
1852
1855
f.getName.endsWith(" .betasty" )
1853
1856
1854
- }
1857
+ extension (pos : SourcePosition )
1858
+ private def adjustedAtEOF : SourcePosition =
1859
+ if pos.span.isSynthetic
1860
+ && pos.span.isZeroExtent
1861
+ && pos.span.exists
1862
+ && pos.span.start == pos.source.length
1863
+ && pos.source(pos.span.start - 1 ) == '\n '
1864
+ then
1865
+ pos.withSpan(pos.span.shift(- 1 ))
1866
+ else
1867
+ pos
0 commit comments