Skip to content

Commit 584a0f0

Browse files
committed
draft
1 parent 896bd70 commit 584a0f0

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
629629

630630
if (compilerCrashed) Some(s"Compiler crashed when compiling: ${testSource.title}")
631631
else if (actualErrors == 0) Some(s"\nNo errors found when compiling neg test $testSource")
632+
else if (expectedErrors == 0) Some(s"\nNo errors defined in $testSource")
632633
else if (expectedErrors != actualErrors) Some(s"\nWrong number of errors encountered when compiling $testSource, expected: $expectedErrors, actual: $actualErrors")
633634
else if (hasMissingAnnotations) Some(s"\nErrors found on incorrect row numbers when compiling $testSource")
634635
else if (!errorMap.isEmpty) Some(s"\nExpected error(s) have {<error position>=<unreported error>}: $errorMap")
@@ -651,25 +652,30 @@ trait ParallelTesting extends RunnerOrchestration { self =>
651652
val errorMap = new HashMap[String, Integer]()
652653
var expectedErrors = 0
653654
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+
}
665668

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+
}
671674

672-
expectedErrors += noposErrors + errors
675+
expectedErrors += noposErrors + errors
676+
}
677+
} finally {
678+
try { src.close() } catch { case _:Throwable => /* ignore failures during close */ }
673679
}
674680
}
675681

0 commit comments

Comments
 (0)