@@ -785,43 +785,29 @@ trait ParallelTesting extends RunnerOrchestration { self =>
785785 //
786786 // We collect these in a map `"file:row" -> numberOfErrors`, for
787787 // 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
789790 val errorMap = new HashMap [String , Integer ]()
790791 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
791797 files.filter(isSourceFile).foreach { file =>
792798 Using (Source .fromFile(file, StandardCharsets .UTF_8 .name)) { source =>
793799 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(1 ) match
802+ case " nopos-" => bump(" nopos" )
803+ case " anypos-" => bump(" anypos" )
804+ case _ => bump(s " ${file.getPath}: ${lineNbr+ 1 }" )
816805 }
817-
818- expectedErrors += anyposErrors + noposErrors + errors
819806 }
820807 }.get
821808 }
822-
823809 (errorMap, expectedErrors)
824- }
810+ end getErrorMapAndExpectedCount
825811
826812 // return unfulfilled expected errors and unexpected diagnostics
827813 def getMissingExpectedErrors (errorMap : HashMap [String , Integer ], reporterErrors : Iterator [Diagnostic ]): (List [String ], List [String ]) =
0 commit comments