@@ -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
@@ -996,29 +996,33 @@ trait ParallelTesting extends RunnerOrchestration { self =>
996
996
(errorMap, expectedErrors)
997
997
end getErrorMapAndExpectedCount
998
998
999
- // return unfulfilled expected errors and unexpected diagnostics
999
+ // return unfulfilled expected errors and unexpected diagnostics.
1000
+ // the errorMap of expected errors is drained and returned as unfulfilled.
1001
+ // a diagnostic at EOF after NL is recorded at the preceding line,
1002
+ // to obviate `anypos-error` in that case.
1000
1003
def getMissingExpectedErrors (errorMap : HashMap [String , Integer ], reporterErrors : Iterator [Diagnostic ]): (List [String ], List [String ]) =
1001
1004
val unexpected, unpositioned = ListBuffer .empty[String ]
1002
1005
// For some reason, absolute paths leak from the compiler itself...
1003
1006
def relativize (path : String ): String = path.split(JFile .separatorChar).dropWhile(_ != " tests" ).mkString(JFile .separator)
1004
1007
def seenAt (key : String ): Boolean =
1005
1008
errorMap.get(key) match
1006
- case null => false
1007
- case 1 => errorMap.remove(key); true
1008
- case n => errorMap.put(key, n - 1 ); true
1009
+ case null => false
1010
+ case 1 => errorMap.remove(key); true
1011
+ case n => errorMap.put(key, n - 1 ); true
1009
1012
def sawDiagnostic (d : Diagnostic ): Unit =
1010
- d.pos.nonInlined match
1011
- case srcpos if srcpos.exists =>
1012
- val key = s " ${relativize(srcpos.source.file.toString)}: ${srcpos.line + 1 }"
1013
- if ! seenAt(key) then unexpected += key
1014
- case srcpos =>
1015
- if ! seenAt(" nopos" ) then unpositioned += relativize(srcpos.source.file.toString)
1013
+ val srcpos = d.pos.nonInlined.adjustedAtEOF
1014
+ val relatively = relativize(srcpos.source.file.toString)
1015
+ if srcpos.exists then
1016
+ val key = s " ${relatively}: ${srcpos.line + 1 }"
1017
+ if ! seenAt(key) then unexpected += key
1018
+ else
1019
+ if ! seenAt(" nopos" ) then unpositioned += relatively
1016
1020
1017
1021
reporterErrors.foreach(sawDiagnostic)
1018
1022
1019
- errorMap.get(" anypos" ) match
1020
- case n if n == unexpected.size => errorMap.remove(" anypos" ) ; unexpected.clear( )
1021
- case _ =>
1023
+ if errorMap.get(" anypos" ) == unexpected.size then
1024
+ errorMap.remove(" anypos" )
1025
+ unexpected.clear()
1022
1026
1023
1027
(errorMap.asScala.keys.toList, (unexpected ++ unpositioned).toList)
1024
1028
end getMissingExpectedErrors
@@ -1838,9 +1842,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1838
1842
def isUserDebugging : Boolean =
1839
1843
val mxBean = ManagementFactory .getRuntimeMXBean
1840
1844
mxBean.getInputArguments.asScala.exists(_.contains(" jdwp" ))
1841
- }
1842
1845
1843
- object ParallelTesting {
1846
+ object ParallelTesting :
1844
1847
1845
1848
def defaultOutputDir : String = " out" + JFile .separator
1846
1849
@@ -1855,4 +1858,14 @@ object ParallelTesting {
1855
1858
def isBestEffortTastyFile (f : JFile ): Boolean =
1856
1859
f.getName.endsWith(" .betasty" )
1857
1860
1858
- }
1861
+ extension (pos : SourcePosition )
1862
+ private def adjustedAtEOF : SourcePosition =
1863
+ if pos.span.isSynthetic
1864
+ && pos.span.isZeroExtent
1865
+ && pos.span.exists
1866
+ && pos.span.start == pos.source.length
1867
+ && pos.source(pos.span.start - 1 ) == '\n '
1868
+ then
1869
+ pos.withSpan(pos.span.shift(- 1 ))
1870
+ else
1871
+ pos
0 commit comments