Skip to content

Commit 428135c

Browse files
committed
Only complete tests after run has been performed
1 parent 7a63f42 commit 428135c

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

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

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
205205
private[this] var _errorCount = 0
206206
def errorCount: Int = _errorCount
207207

208-
private[this] var _testSourcesCompiled = 0
209-
private def testSourcesCompiled: Int = _testSourcesCompiled
208+
private[this] var _testSourcesCompleted = 0
209+
private def testSourcesCompleted: Int = _testSourcesCompleted
210210

211211
/** Complete the current compilation with the amount of errors encountered */
212-
protected final def registerCompilation(errors: Int) = synchronized {
213-
_testSourcesCompiled += 1
212+
protected final def registerCompletion(errors: Int) = synchronized {
213+
_testSourcesCompleted += 1
214214
_errorCount += errors
215215
}
216216

@@ -249,7 +249,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
249249
private def createProgressMonitor: Runnable = new Runnable {
250250
def run(): Unit = {
251251
val start = System.currentTimeMillis
252-
var tCompiled = testSourcesCompiled
252+
var tCompiled = testSourcesCompleted
253253
while (tCompiled < sourceCount) {
254254
val timestamp = (System.currentTimeMillis - start) / 1000
255255
val progress = (tCompiled.toDouble / sourceCount * 40).toInt
@@ -258,15 +258,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
258258
"[" + ("=" * (math.max(progress - 1, 0))) +
259259
(if (progress > 0) ">" else "") +
260260
(" " * (39 - progress)) +
261-
s"] compiling ($tCompiled/$sourceCount, ${timestamp}s)\r"
261+
s"] completed ($tCompiled/$sourceCount, ${timestamp}s)\r"
262262
)
263263

264264
Thread.sleep(100)
265-
tCompiled = testSourcesCompiled
265+
tCompiled = testSourcesCompleted
266266
}
267267
// println, otherwise no newline and cursor at start of line
268268
realStdout.println(
269-
s"[=======================================] compiled ($sourceCount/$sourceCount, " +
269+
s"[=======================================] completed ($sourceCount/$sourceCount, " +
270270
s"${(System.currentTimeMillis - start) / 1000}s) "
271271
)
272272
}
@@ -285,7 +285,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
285285
// run should fail
286286
failTestSource(testSource)
287287
e.printStackTrace()
288-
registerCompilation(1)
288+
registerCompletion(1)
289289
throw e
290290
}
291291
}
@@ -350,7 +350,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
350350
}
351351

352352
private[ParallelTesting] def executeTestSuite(): this.type = {
353-
assert(_testSourcesCompiled == 0, "not allowed to re-use a `CompileRun`")
353+
assert(_testSourcesCompleted == 0, "not allowed to re-use a `CompileRun`")
354354

355355
if (filteredSources.nonEmpty) {
356356
val pool = threadLimit match {
@@ -396,7 +396,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
396396
testSource match {
397397
case testSource @ JointCompilationSource(_, files, flags, outDir) => {
398398
val reporter = compile(testSource.sourceFiles, flags, false, outDir)
399-
registerCompilation(reporter.errorCount)
399+
registerCompletion(reporter.errorCount)
400400

401401
if (reporter.errorCount > 0)
402402
echoBuildInstructions(reporter, testSource, reporter.errorCount, reporter.warningCount)
@@ -413,7 +413,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
413413

414414
def warningCount = reporters.foldLeft(0)(_ + _.warningCount)
415415

416-
registerCompilation(errorCount)
416+
registerCompletion(errorCount)
417417

418418
if (errorCount > 0)
419419
echoBuildInstructions(reporters.head, testSource, errorCount, warningCount)
@@ -487,7 +487,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
487487
if (reporter.errorCount > 0)
488488
echoBuildInstructions(reporter, testSource, reporter.errorCount, reporter.warningCount)
489489

490-
registerCompilation(reporter.errorCount)
491490
(reporter.errorCount, reporter.warningCount, checkFile.isDefined, () => verifyOutput(checkFile.get, outDir, testSource, reporter.warningCount))
492491
}
493492

@@ -506,28 +505,33 @@ trait ParallelTesting extends RunnerOrchestration { self =>
506505

507506
if (errorCount > 0) fail()
508507

509-
registerCompilation(errorCount)
510508
(errorCount, warningCount, checkFile.exists, () => verifyOutput(checkFile, outDir, testSource, warningCount))
511509
}
512510
}
513511

514512
if (errorCount == 0 && hasCheckFile) verifier()
515513
else if (errorCount == 0) runMain(testSource.classPath) match {
516-
case Success(_) => // success!
517-
case Failure(output) =>
518-
echo(s" failed when running '${testSource.title}'")
519-
echo(output)
520-
failTestSource(testSource)
521-
case Timeout =>
522-
echo(" failed because test " + testSource.title + " timed out")
523-
failTestSource(testSource, Some("test timed out"))
524-
}
514+
case Success(_) => // success!
515+
case Failure(output) =>
516+
echo(s" failed when running '${testSource.title}'")
517+
echo(output)
518+
failTestSource(testSource)
519+
case Timeout =>
520+
echo(" failed because test " + testSource.title + " timed out")
521+
failTestSource(testSource, Some("test timed out"))
522+
}
525523
else if (errorCount > 0) {
526524
echo(s"\n Compilation failed for: '$testSource'")
527525
val buildInstr = testSource.buildInstructions(errorCount, warningCount)
528526
addFailureInstruction(buildInstr)
529527
failTestSource(testSource)
530528
}
529+
else {
530+
realStdout.println("Got a super weird error that I haven't handled yet")
531+
realStdout.println("errorCount: " + errorCount)
532+
realStdout.println("test: " + testSource.title + " " + testSource.name)
533+
}
534+
registerCompletion(errorCount)
531535
}
532536
}
533537
}
@@ -626,7 +630,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
626630
failTestSource(testSource)
627631
}
628632

629-
registerCompilation(actualErrors)
633+
registerCompletion(actualErrors)
630634
}
631635
}
632636
}

0 commit comments

Comments
 (0)