@@ -629,6 +629,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
629
629
630
630
if (compilerCrashed) Some (s " Compiler crashed when compiling: ${testSource.title}" )
631
631
else if (actualErrors == 0 ) Some (s " \n No errors found when compiling neg test $testSource" )
632
+ else if (expectedErrors == 0 ) Some (s " \n No errors defined in $testSource" )
632
633
else if (expectedErrors != actualErrors) Some (s " \n Wrong number of errors encountered when compiling $testSource, expected: $expectedErrors, actual: $actualErrors" )
633
634
else if (hasMissingAnnotations) Some (s " \n Errors found on incorrect row numbers when compiling $testSource" )
634
635
else if (! errorMap.isEmpty) Some (s " \n Expected error(s) have {<error position>=<unreported error>}: $errorMap" )
@@ -651,25 +652,30 @@ trait ParallelTesting extends RunnerOrchestration { self =>
651
652
val errorMap = new HashMap [String , Integer ]()
652
653
var expectedErrors = 0
653
654
files.filter(_.getName.endsWith(" .scala" )).foreach { file =>
654
- Source .fromFile(file, " UTF-8" ).getLines().zipWithIndex.foreach { case (line, lineNbr) =>
655
- val errors = line.toSeq.sliding(" // error" .length).count(_.unwrap == " // error" )
656
- if (errors > 0 )
657
- errorMap.put(s " ${file.getPath}: ${lineNbr}" , errors)
658
-
659
- val noposErrors = line.toSeq.sliding(" // nopos-error" .length).count(_.unwrap == " // nopos-error" )
660
- if (noposErrors > 0 ) {
661
- val nopos = errorMap.get(" nopos" )
662
- val existing : Integer = if (nopos eq null ) 0 else nopos
663
- errorMap.put(" nopos" , noposErrors + existing)
664
- }
655
+ val src = Source .fromFile(file, " UTF-8" )
656
+ try {
657
+ src.getLines().zipWithIndex.foreach { case (line, lineNbr) =>
658
+ val errors = line.toSeq.sliding(" // error" .length).count(_.unwrap == " // error" )
659
+ if (errors > 0 )
660
+ errorMap.put(s " ${file.getPath}: ${lineNbr}" , errors)
661
+
662
+ val noposErrors = line.toSeq.sliding(" // nopos-error" .length).count(_.unwrap == " // nopos-error" )
663
+ if (noposErrors > 0 ) {
664
+ val nopos = errorMap.get(" nopos" )
665
+ val existing : Integer = if (nopos eq null ) 0 else nopos
666
+ errorMap.put(" nopos" , noposErrors + existing)
667
+ }
665
668
666
- val possibleTypos = List (" //error" -> " // error" , " //nopos-error" -> " // nopos-error" )
667
- for ((possibleTypo, expected) <- possibleTypos) {
668
- if (line.contains(possibleTypo))
669
- echo(s " Warning: Possible typo in error tag in file ${file.getCanonicalPath}: $lineNbr: found ` $possibleTypo` but expected ` $expected` " )
670
- }
669
+ val possibleTypos = List (" //error" -> " // error" , " //nopos-error" -> " // nopos-error" )
670
+ for ((possibleTypo, expected) <- possibleTypos) {
671
+ if (line.contains(possibleTypo))
672
+ echo(s " Warning: Possible typo in error tag in file ${file.getCanonicalPath}: $lineNbr: found ` $possibleTypo` but expected ` $expected` " )
673
+ }
671
674
672
- expectedErrors += noposErrors + errors
675
+ expectedErrors += noposErrors + errors
676
+ }
677
+ } finally {
678
+ try { src.close() } catch { case _:Throwable => /* ignore failures during close */ }
673
679
}
674
680
}
675
681
0 commit comments