Skip to content

Commit 639d329

Browse files
committed
Only complete tests after run has been performed
1 parent 56a0ed0 commit 639d329

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
@@ -206,12 +206,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
206206
private[this] var _errorCount = 0
207207
def errorCount: Int = _errorCount
208208

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

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

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

265265
Thread.sleep(100)
266-
tCompiled = testSourcesCompiled
266+
tCompiled = testSourcesCompleted
267267
}
268268
// println, otherwise no newline and cursor at start of line
269269
realStdout.println(
270-
s"[=======================================] compiled ($sourceCount/$sourceCount, " +
270+
s"[=======================================] completed ($sourceCount/$sourceCount, " +
271271
s"${(System.currentTimeMillis - start) / 1000}s) "
272272
)
273273
}
@@ -286,7 +286,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
286286
// run should fail
287287
failTestSource(testSource)
288288
e.printStackTrace()
289-
registerCompilation(1)
289+
registerCompletion(1)
290290
throw e
291291
}
292292
}
@@ -351,7 +351,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
351351
}
352352

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

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

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

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

417-
registerCompilation(errorCount)
417+
registerCompletion(errorCount)
418418

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

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

@@ -507,28 +506,33 @@ trait ParallelTesting extends RunnerOrchestration { self =>
507506

508507
if (errorCount > 0) fail()
509508

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

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

630-
registerCompilation(actualErrors)
634+
registerCompletion(actualErrors)
631635
}
632636
}
633637
}

0 commit comments

Comments
 (0)