Skip to content

Commit 11e4259

Browse files
committed
Remove summaryReport.addCleanup
We use ParallelTesting.cleanup instead
1 parent 77d10b5 commit 11e4259

File tree

4 files changed

+29
-41
lines changed

4 files changed

+29
-41
lines changed

Diff for: compiler/test/dotty/tools/debug/DebugTests.scala

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import dotty.Properties
55
import dotty.tools.dotc.reporting.TestReporter
66
import dotty.tools.io.JFile
77
import dotty.tools.vulpix.*
8+
import org.junit.AfterClass
89
import org.junit.Test
910

1011
import java.util.concurrent.TimeoutException
@@ -31,6 +32,9 @@ object DebugTests extends ParallelTesting:
3132
override def debugMode = true
3233

3334
implicit val summaryReport: SummaryReporting = new SummaryReport
35+
@AfterClass def tearDown(): Unit =
36+
super.cleanup()
37+
summaryReport.echoSummary()
3438

3539
extension (test: CompilationTest)
3640
private def checkDebug()(implicit summaryReport: SummaryReporting): test.type =

Diff for: compiler/test/dotty/tools/vulpix/RunnerOrchestration.scala

-7
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ trait RunnerOrchestration {
8585
* it died
8686
*/
8787
private class RunnerMonitor {
88-
/** Did add hook to kill the child VMs? */
89-
private val didAddCleanupCallback = new AtomicBoolean(false)
9088

9189
def runMain(classPath: String)(implicit summaryReport: SummaryReporting): Status =
9290
withRunner(_.runMain(classPath))
@@ -118,7 +116,6 @@ trait RunnerOrchestration {
118116
end RunnerProcess
119117

120118
private class Runner(private var process: RunnerProcess):
121-
122119
/** Checks if `process` is still alive
123120
*
124121
* When `process.exitValue()` is called on an active process the caught
@@ -236,10 +233,6 @@ trait RunnerOrchestration {
236233
}
237234

238235
private def withRunner[T](op: Runner => T)(using summaryReport: SummaryReporting): T =
239-
// If for some reason the test runner (i.e. sbt) doesn't kill the VM,
240-
// we need to clean up ourselves.
241-
if didAddCleanupCallback.compareAndSet(false, true) then
242-
summaryReport.addCleanup(() => killAll())
243236
val runner = getRunner()
244237
val result = op(runner)
245238
freeRunner(runner)

Diff for: compiler/test/dotty/tools/vulpix/SummaryReport.scala

-11
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ trait SummaryReporting {
3030
/** Add a message that will be issued in the beginning of the summary */
3131
def addStartingMessage(msg: String): Unit
3232

33-
/** Add a cleanup hook to be run upon completion */
34-
def addCleanup(f: () => Unit): Unit
35-
3633
/** Echo the summary report to the appropriate locations */
3734
def echoSummary(): Unit
3835

@@ -51,7 +48,6 @@ final class NoSummaryReport extends SummaryReporting {
5148
def addFailedTest(msg: FailedTestInfo): Unit = ()
5249
def addReproduceInstruction(instr: String): Unit = ()
5350
def addStartingMessage(msg: String): Unit = ()
54-
def addCleanup(f: () => Unit): Unit = ()
5551
def echoSummary(): Unit = ()
5652
def echoToLog(msg: String): Unit = ()
5753
def echoToLog(it: Iterator[String]): Unit = ()
@@ -67,7 +63,6 @@ final class SummaryReport extends SummaryReporting {
6763
private val startingMessages = new java.util.concurrent.ConcurrentLinkedDeque[String]
6864
private val failedTests = new java.util.concurrent.ConcurrentLinkedDeque[FailedTestInfo]
6965
private val reproduceInstructions = new java.util.concurrent.ConcurrentLinkedDeque[String]
70-
private val cleanUps = new java.util.concurrent.ConcurrentLinkedDeque[() => Unit]
7166

7267
private var passed = 0
7368
private var failed = 0
@@ -87,9 +82,6 @@ final class SummaryReport extends SummaryReporting {
8782
def addStartingMessage(msg: String): Unit =
8883
startingMessages.add(msg)
8984

90-
def addCleanup(f: () => Unit): Unit =
91-
cleanUps.add(f)
92-
9385
/** Both echoes the summary to stdout and prints to file */
9486
def echoSummary(): Unit = {
9587
import SummaryReport._
@@ -131,9 +123,6 @@ final class SummaryReport extends SummaryReporting {
131123
if (!isInteractive) println(rep.toString)
132124

133125
TestReporter.logPrintln(rep.toString)
134-
135-
// Perform cleanup callback:
136-
if (!cleanUps.isEmpty()) cleanUps.asScala.foreach(_.apply())
137126
}
138127

139128
private def removeColors(msg: String): String =

Diff for: sjs-compiler-tests/test/scala/dotty/tools/dotc/ScalaJSCompilationTests.scala

+25-23
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,41 @@ package dotty
22
package tools
33
package dotc
44

5-
import org.junit.{ Test => JUnitTest, BeforeClass, AfterClass }
5+
import org.junit.{ Test, BeforeClass, AfterClass }
66
import org.junit.experimental.categories.Category
77

88
import scala.concurrent.duration._
99
import reporting.TestReporter
1010
import vulpix._
1111

1212
@Category(Array(classOf[ScalaJSCompilationTests]))
13-
class ScalaJSCompilationTests extends ParallelTesting {
13+
class ScalaJSCompilationTests {
1414
import ParallelTesting._
1515
import TestConfiguration._
1616
import ScalaJSCompilationTests._
1717
import CompilationTest.aggregateTests
1818

19-
// Test suite configuration --------------------------------------------------
19+
// Negative tests ------------------------------------------------------------
20+
21+
@Test def negScalaJS: Unit = {
22+
implicit val testGroup: TestGroup = TestGroup("negScalaJS")
23+
aggregateTests(
24+
compileFilesInDir("tests/neg-scalajs", scalaJSOptions),
25+
).checkExpectedErrors()
26+
}
27+
28+
@Test def runScalaJS: Unit = {
29+
implicit val testGroup: TestGroup = TestGroup("runScalaJS")
30+
aggregateTests(
31+
compileFilesInDir("tests/run", scalaJSOptions),
32+
).checkRuns()
33+
}
34+
}
35+
36+
object ScalaJSCompilationTests extends ParallelTesting {
37+
implicit val summaryReport: SummaryReporting = new SummaryReport
2038

39+
// Test suite configuration --------------------------------------------------
2140
def maxDuration = 60.seconds
2241
def numberOfSlaves = 5
2342
def safeMode = Properties.testsSafeMode
@@ -26,14 +45,9 @@ class ScalaJSCompilationTests extends ParallelTesting {
2645
def updateCheckFiles: Boolean = Properties.testsUpdateCheckfile
2746
def failedTests = TestReporter.lastRunFailedTests
2847

29-
// Negative tests ------------------------------------------------------------
30-
31-
@JUnitTest def negScalaJS: Unit = {
32-
implicit val testGroup: TestGroup = TestGroup("negScalaJS")
33-
aggregateTests(
34-
compileFilesInDir("tests/neg-scalajs", scalaJSOptions),
35-
).checkExpectedErrors()
36-
}
48+
@AfterClass def tearDown(): Unit =
49+
cleanup()
50+
summaryReport.echoSummary()
3751

3852
// Run tests -----------------------------------------------------------------
3953

@@ -57,16 +71,4 @@ class ScalaJSCompilationTests extends ParallelTesting {
5771
t.printStackTrace(new java.io.PrintWriter(writer))
5872
Failure(writer.toString())
5973
end runMain
60-
61-
@JUnitTest def runScalaJS: Unit = {
62-
implicit val testGroup: TestGroup = TestGroup("runScalaJS")
63-
aggregateTests(
64-
compileFilesInDir("tests/run", scalaJSOptions),
65-
).checkRuns()
66-
}
67-
}
68-
69-
object ScalaJSCompilationTests {
70-
implicit val summaryReport: SummaryReporting = new SummaryReport
71-
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()
7274
}

0 commit comments

Comments
 (0)