Skip to content

Commit c9f692a

Browse files
committed
if one test (TestSource) in a suite (ParallelTesting.Test) is ignored, still report failures in other tests of the suite
1 parent 050c214 commit c9f692a

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

compiler/test/dotty/tools/dotc/reporting/TestReporter.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
3232
private var _didCrash = false
3333
final def compilerCrashed: Boolean = _didCrash
3434

35+
private var _skip: Boolean = false
36+
final def setSkip(): Unit = _skip = true
37+
final def skipped: Boolean = _skip
38+
3539
protected final def inlineInfo(pos: SourcePosition)(using Context): String =
3640
if (pos.exists) {
3741
if (pos.outer.exists)

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

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
281281
private final def onComplete(testSource: TestSource, reportersOrCrash: Try[Seq[TestReporter]], logger: LoggedRunnable): Unit =
282282
reportersOrCrash match {
283283
case TryFailure(exn) => onFailure(testSource, Nil, logger, Some(s"Fatal compiler crash when compiling: ${testSource.title}:\n${exn.getMessage}${exn.getStackTrace.map("\n\tat " + _).mkString}"))
284-
case TrySuccess(reporters) => maybeFailureMessage(testSource, reporters) match {
285-
case Some(msg) => onFailure(testSource, reporters, logger, Option(msg).filter(_.nonEmpty))
286-
case None => onSuccess(testSource, reporters, logger)
287-
}
284+
case TrySuccess(reporters) if !reporters.exists(_.skipped) =>
285+
maybeFailureMessage(testSource, reporters) match {
286+
case Some(msg) => onFailure(testSource, reporters, logger, Option(msg).filter(_.nonEmpty))
287+
case None => onSuccess(testSource, reporters, logger)
288+
}
289+
case _ =>
288290
}
289291

290292
/**
@@ -392,9 +394,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
392394
def failureCount: Int = _failureCount
393395

394396
private var _skipCount = 0
395-
protected final def skip(): Unit = synchronized { _skipCount += 1 }
397+
protected final def registerSkip(): Unit = synchronized { _skipCount += 1 }
396398
def skipCount: Int = _skipCount
397-
def skipped: Boolean = skipCount > 0
398399

399400
protected def logBuildInstructions(testSource: TestSource, reporters: Seq[TestReporter]) = {
400401
val (errCount, warnCount) = countErrorsAndWarnings(reporters)
@@ -529,7 +530,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
529530
fail(failure = JavaCompilationFailure(javaErrors.get))
530531
}
531532
else
532-
skip()
533+
registerSkip()
534+
reporter.setSkip()
533535
end if
534536

535537
reporter
@@ -731,8 +733,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
731733
}
732734

733735
private def verifyOutput(checkFile: Option[JFile], dir: JFile, testSource: TestSource, warnings: Int, reporters: Seq[TestReporter], logger: LoggedRunnable) = {
734-
if skipped then ()
735-
else if Properties.testsNoRun then addNoRunWarning()
736+
if Properties.testsNoRun then addNoRunWarning()
736737
else runMain(testSource.runClassPath, testSource.allToolArgs) match {
737738
case Success(output) => checkFile match {
738739
case Some(file) if file.exists => diffTest(testSource, file, output.linesIterator.toList, reporters, logger)
@@ -756,7 +757,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
756757
extends Test(testSources, times, threadLimit, suppressAllOutput) {
757758
override def suppressErrors = true
758759

759-
override def maybeFailureMessage(testSource: TestSource, reporters: Seq[TestReporter]): Option[String] = if skipped then None else
760+
override def maybeFailureMessage(testSource: TestSource, reporters: Seq[TestReporter]): Option[String] =
760761
def compilerCrashed = reporters.exists(_.compilerCrashed)
761762
lazy val (errorMap, expectedErrors) = getErrorMapAndExpectedCount(testSource.sourceFiles.toIndexedSeq)
762763
lazy val actualErrors = reporters.foldLeft(0)(_ + _.errorCount)
@@ -997,7 +998,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
997998
if (!shouldFail && test.didFail) {
998999
fail(s"Expected no errors when compiling, failed for the following reason(s):\n${reasonsForFailure(test)}\n")
9991000
}
1000-
else if (shouldFail && !test.didFail) {
1001+
else if (shouldFail && !test.didFail && test.skipCount == 0) {
10011002
fail("Pos test should have failed, but didn't")
10021003
}
10031004

@@ -1013,12 +1014,10 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10131014

10141015
cleanup()
10151016

1016-
if !test.skipped then
1017-
if shouldFail && !test.didFail then
1018-
fail(s"Neg test shouldn't have failed, but did. Reasons:\n${ reasonsForFailure(test) }")
1019-
else if !shouldFail && test.didFail then
1020-
fail("Neg test should have failed, but did not")
1021-
end if
1017+
if shouldFail && !test.didFail && test.skipCount == 0 then
1018+
fail(s"Neg test shouldn't have failed, but did. Reasons:\n${ reasonsForFailure(test) }")
1019+
else if !shouldFail && test.didFail then
1020+
fail("Neg test should have failed, but did not")
10221021

10231022
this
10241023
end checkExpectedErrors
@@ -1046,12 +1045,10 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10461045

10471046
cleanup()
10481047

1049-
if !test.skipped then
1050-
if !shouldFail && test.didFail then
1051-
fail(s"Run test failed, but should not, reasons:\n${ reasonsForFailure(test) }")
1052-
else if shouldFail && !test.didFail then
1053-
fail("Run test should have failed, but did not")
1054-
end if
1048+
if !shouldFail && test.didFail then
1049+
fail(s"Run test failed, but should not, reasons:\n${ reasonsForFailure(test) }")
1050+
else if shouldFail && !test.didFail && test.skipCount == 0 then
1051+
fail("Run test should have failed, but did not")
10551052

10561053
this
10571054
}

0 commit comments

Comments
 (0)