@@ -785,43 +785,32 @@ trait ParallelTesting extends RunnerOrchestration { self =>
785
785
//
786
786
// We collect these in a map `"file:row" -> numberOfErrors`, for
787
787
// nopos errors we save them in `"file" -> numberOfNoPosErrors`
788
- def getErrorMapAndExpectedCount (files : Seq [JFile ]): (HashMap [String , Integer ], Int ) = {
788
+ def getErrorMapAndExpectedCount (files : Seq [JFile ]): (HashMap [String , Integer ], Int ) =
789
+ val comment = raw " //( *)(nopos-|anypos-)?error " .r
789
790
val errorMap = new HashMap [String , Integer ]()
790
791
var expectedErrors = 0
792
+ def bump (key : String ): Unit =
793
+ errorMap.get(key) match
794
+ case null => errorMap.put(key, 1 )
795
+ case n => errorMap.put(key, n+ 1 )
796
+ expectedErrors += 1
791
797
files.filter(isSourceFile).foreach { file =>
792
798
Using (Source .fromFile(file, StandardCharsets .UTF_8 .name)) { source =>
793
799
source.getLines.zipWithIndex.foreach { case (line, lineNbr) =>
794
- val errors = line.toSeq.sliding(" // error" .length).count(_.unwrap == " // error" )
795
- if (errors > 0 )
796
- errorMap.put(s " ${file.getPath}: ${lineNbr+ 1 }" , errors)
797
-
798
- val noposErrors = line.toSeq.sliding(" // nopos-error" .length).count(_.unwrap == " // nopos-error" )
799
- if (noposErrors > 0 ) {
800
- val nopos = errorMap.get(" nopos" )
801
- val existing : Integer = if (nopos eq null ) 0 else nopos
802
- errorMap.put(" nopos" , noposErrors + existing)
803
- }
804
-
805
- val anyposErrors = line.toSeq.sliding(" // anypos-error" .length).count(_.unwrap == " // anypos-error" )
806
- if (anyposErrors > 0 ) {
807
- val anypos = errorMap.get(" anypos" )
808
- val existing : Integer = if (anypos eq null ) 0 else anypos
809
- errorMap.put(" anypos" , anyposErrors + existing)
810
- }
811
-
812
- val possibleTypos = List (" //error" -> " // error" , " //nopos-error" -> " // nopos-error" , " //anypos-error" -> " // anypos-error" )
813
- for ((possibleTypo, expected) <- possibleTypos) {
814
- if (line.contains(possibleTypo))
815
- echo(s " Warning: Possible typo in error tag in file ${file.getCanonicalPath}: $lineNbr: found ` $possibleTypo` but expected ` $expected` " )
800
+ comment.findAllMatchIn(line).foreach { m =>
801
+ m.group(2 ) match
802
+ case prefix if m.group(1 ).isEmpty =>
803
+ val what = Option (prefix).getOrElse(" " )
804
+ echo(s " Warning: ${file.getCanonicalPath}: ${lineNbr}: found `// ${what}error` but expected `// ${what}error`, skipping comment " )
805
+ case " nopos-" => bump(" nopos" )
806
+ case " anypos-" => bump(" anypos" )
807
+ case _ => bump(s " ${file.getPath}: ${lineNbr+ 1 }" )
816
808
}
817
-
818
- expectedErrors += anyposErrors + noposErrors + errors
819
809
}
820
810
}.get
821
811
}
822
-
823
812
(errorMap, expectedErrors)
824
- }
813
+ end getErrorMapAndExpectedCount
825
814
826
815
// return unfulfilled expected errors and unexpected diagnostics
827
816
def getMissingExpectedErrors (errorMap : HashMap [String , Integer ], reporterErrors : Iterator [Diagnostic ]): (List [String ], List [String ]) =
0 commit comments