Skip to content

Commit b22331e

Browse files
Merge pull request #9973 from dotty-staging/windows-ci
Enable Scala.js test
2 parents d04d684 + 6e9986d commit b22331e

8 files changed

+108
-75
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ jobs:
119119
run: sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test"
120120
shell: cmd
121121

122-
# - name: Scala.js Test
123-
# run: sbt ";sjsJUnitTests/test"
124-
# shell: cmd
122+
- name: Scala.js Test
123+
run: sbt ";sjsJUnitTests/test ;sjsCompilerTests/test"
124+
shell: cmd
125125

126126
community_build:
127127
runs-on: [self-hosted, Linux]

compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
2222
// Test suite configuration --------------------------------------------------
2323

2424
def maxDuration = 60.seconds
25-
def numberOfSlaves = 5
25+
def numberOfSlaves = Runtime.getRuntime().availableProcessors()
2626
def safeMode = Properties.testsSafeMode
2727
def isInteractive = SummaryReport.isInteractive
2828
def testFilter = Properties.testsFilter
2929
def updateCheckFiles: Boolean = Properties.testsUpdateCheckfile
3030

3131
// Positive tests ------------------------------------------------------------
3232

33-
@Test def posMacros: Unit = if (!scala.util.Properties.isWin) {
33+
@Test def posMacros: Unit = {
3434
implicit val testGroup: TestGroup = TestGroup("compilePosMacros")
3535
aggregateTests(
3636
compileFilesInDir("tests/bench", defaultOptions),
@@ -129,17 +129,20 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
129129
)
130130
}.checkRuns()
131131

132-
@Test def runWithCompiler: Unit = if (!scala.util.Properties.isWin) {
132+
@Test def runWithCompiler: Unit = {
133133
implicit val testGroup: TestGroup = TestGroup("runWithCompiler")
134-
aggregateTests(
134+
val basicTests = List(
135135
compileFilesInDir("tests/run-with-compiler", withCompilerOptions),
136136
compileFilesInDir("tests/run-staging", withStagingOptions),
137-
compileFilesInDir("tests/run-custom-args/tasty-inspector", withTastyInspectorOptions),
138-
compileDir("tests/run-custom-args/tasty-interpreter", withTastyInspectorOptions),
139-
).checkRuns()
137+
compileFilesInDir("tests/run-custom-args/tasty-inspector", withTastyInspectorOptions)
138+
)
139+
val tests =
140+
if (scala.util.Properties.isWin) basicTests
141+
else compileDir("tests/run-custom-args/tasty-interpreter", withTastyInspectorOptions) :: basicTests
142+
aggregateTests(tests: _*).checkRuns()
140143
}
141144

142-
@Test def runBootstrappedOnly: Unit = if (!scala.util.Properties.isWin) {
145+
@Test def runBootstrappedOnly: Unit = {
143146
implicit val testGroup: TestGroup = TestGroup("runBootstrappedOnly")
144147
aggregateTests(
145148
compileFilesInDir("tests/run-bootstrapped", withCompilerOptions),
@@ -151,7 +154,7 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
151154
// Pickling tests are very memory intensive and as such need to be run with a
152155
// lower level of concurrency as to not kill their running VMs
153156

154-
@Test def picklingWithCompiler: Unit = if (!scala.util.Properties.isWin) {
157+
@Test def picklingWithCompiler: Unit = {
155158
val jvmBackendFilter = FileFilter.exclude(List("BTypes.scala", "Primitives.scala")) // TODO
156159
implicit val testGroup: TestGroup = TestGroup("testPicklingWithCompiler")
157160
aggregateTests(

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,12 @@ import scala.concurrent.duration._
1616
import TestSources.sources
1717
import vulpix._
1818

19-
class CompilationTests extends ParallelTesting {
19+
class CompilationTests {
2020
import ParallelTesting._
2121
import TestConfiguration._
2222
import CompilationTests._
2323
import CompilationTest.aggregateTests
2424

25-
// Test suite configuration --------------------------------------------------
26-
27-
def maxDuration = 45.seconds
28-
def numberOfSlaves = 5
29-
def safeMode = Properties.testsSafeMode
30-
def isInteractive = SummaryReport.isInteractive
31-
def testFilter = Properties.testsFilter
32-
def updateCheckFiles: Boolean = Properties.testsUpdateCheckfile
33-
3425
// Positive tests ------------------------------------------------------------
3526

3627
@Test def pos: Unit = {
@@ -333,7 +324,19 @@ class CompilationTests extends ParallelTesting {
333324

334325
}
335326

336-
object CompilationTests {
327+
object CompilationTests extends ParallelTesting {
328+
// Test suite configuration --------------------------------------------------
329+
330+
def maxDuration = 45.seconds
331+
def numberOfSlaves = Runtime.getRuntime().availableProcessors()
332+
def safeMode = Properties.testsSafeMode
333+
def isInteractive = SummaryReport.isInteractive
334+
def testFilter = Properties.testsFilter
335+
def updateCheckFiles: Boolean = Properties.testsUpdateCheckfile
336+
337337
implicit val summaryReport: SummaryReporting = new SummaryReport
338-
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()
338+
@AfterClass def tearDown(): Unit = {
339+
super.cleanup()
340+
summaryReport.echoSummary()
341+
}
339342
}

compiler/test/dotty/tools/dotc/FromTastyTests.scala

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,10 @@ import java.io.{File => JFile}
99

1010
import scala.concurrent.duration._
1111

12-
class FromTastyTests extends ParallelTesting {
12+
class FromTastyTests {
1313
import TestConfiguration._
1414
import FromTastyTests._
1515

16-
// Test suite configuration --------------------------------------------------
17-
18-
def maxDuration = 30.seconds
19-
def numberOfSlaves = 5
20-
def safeMode = Properties.testsSafeMode
21-
def isInteractive = SummaryReport.isInteractive
22-
def testFilter = Properties.testsFilter
23-
def updateCheckFiles: Boolean = Properties.testsUpdateCheckfile
24-
2516
@Test def posTestFromTasty: Unit = {
2617
// Can be reproduced with
2718
// > sbt
@@ -46,7 +37,19 @@ class FromTastyTests extends ParallelTesting {
4637
}
4738
}
4839

49-
object FromTastyTests {
40+
object FromTastyTests extends ParallelTesting {
41+
// Test suite configuration --------------------------------------------------
42+
43+
def maxDuration = 30.seconds
44+
def numberOfSlaves = Runtime.getRuntime().availableProcessors()
45+
def safeMode = Properties.testsSafeMode
46+
def isInteractive = SummaryReport.isInteractive
47+
def testFilter = Properties.testsFilter
48+
def updateCheckFiles: Boolean = Properties.testsUpdateCheckfile
49+
5050
implicit val summaryReport: SummaryReporting = new SummaryReport
51-
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()
51+
@AfterClass def tearDown(): Unit = {
52+
super.cleanup()
53+
summaryReport.echoSummary()
54+
}
5255
}

compiler/test/dotty/tools/dotc/IdempotencyTests.scala

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,11 @@ import scala.concurrent.duration._
1313
import vulpix._
1414

1515

16-
class IdempotencyTests extends ParallelTesting {
16+
class IdempotencyTests {
1717
import TestConfiguration._
1818
import IdempotencyTests._
1919
import CompilationTest.aggregateTests
2020

21-
// Test suite configuration --------------------------------------------------
22-
23-
def maxDuration = 30.seconds
24-
def numberOfSlaves = 5
25-
def safeMode = Properties.testsSafeMode
26-
def isInteractive = SummaryReport.isInteractive
27-
def testFilter = Properties.testsFilter
28-
def updateCheckFiles: Boolean = Properties.testsUpdateCheckfile
29-
3021
@Category(Array(classOf[SlowTests]))
3122
@Test def idempotency: Unit = {
3223
implicit val testGroup: TestGroup = TestGroup("idempotency")
@@ -71,7 +62,19 @@ class IdempotencyTests extends ParallelTesting {
7162

7263
}
7364

74-
object IdempotencyTests {
65+
object IdempotencyTests extends ParallelTesting {
66+
// Test suite configuration --------------------------------------------------
67+
68+
def maxDuration = 30.seconds
69+
def numberOfSlaves = 5
70+
def safeMode = Properties.testsSafeMode
71+
def isInteractive = SummaryReport.isInteractive
72+
def testFilter = Properties.testsFilter
73+
def updateCheckFiles: Boolean = Properties.testsUpdateCheckfile
74+
7575
implicit val summaryReport: SummaryReporting = new SummaryReport
76-
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()
76+
@AfterClass def tearDown(): Unit = {
77+
super.cleanup()
78+
summaryReport.echoSummary()
79+
}
7780
}

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ trait RunnerOrchestration {
4949
def runMain(classPath: String)(implicit summaryReport: SummaryReporting): Status =
5050
monitor.runMain(classPath)
5151

52+
/** Kill all processes */
53+
def cleanup() = monitor.killAll()
54+
5255
private val monitor = new RunnerMonitor
5356

5457
/** The runner monitor object keeps track of child JVM processes by keeping
@@ -167,14 +170,15 @@ trait RunnerOrchestration {
167170
.start()
168171
}
169172

170-
private val allRunners = List.fill(numberOfSlaves)(new Runner(createProcess))
171-
private val freeRunners = mutable.Queue(allRunners: _*)
173+
private val freeRunners = mutable.Queue.empty[Runner]
172174
private val busyRunners = mutable.Set.empty[Runner]
173175

174176
private def getRunner(): Runner = synchronized {
175-
while (freeRunners.isEmpty) wait()
177+
while (freeRunners.isEmpty && busyRunners.size >= numberOfSlaves) wait()
176178

177-
val runner = freeRunners.dequeue()
179+
val runner =
180+
if (freeRunners.isEmpty) new Runner(createProcess)
181+
else freeRunners.dequeue()
178182
busyRunners += runner
179183

180184
notify()
@@ -194,7 +198,10 @@ trait RunnerOrchestration {
194198
result
195199
}
196200

197-
private def killAll(): Unit = allRunners.foreach(_.kill())
201+
def killAll(): Unit = {
202+
freeRunners.foreach(_.kill())
203+
busyRunners.foreach(_.kill())
204+
}
198205

199206
// On shutdown, we need to kill all runners:
200207
sys.addShutdownHook(killAll())
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dotty.tools
22
package vulpix
33

4-
import org.junit.Test
4+
import org.junit.{ Test, AfterClass }
55
import org.junit.experimental.categories.Category
66
import scala.concurrent.duration._
77
import TestConfiguration._
@@ -11,14 +11,8 @@ import TestConfiguration._
1111
* output against an expected result.
1212
*/
1313
@Category(Array(classOf[dotty.VulpixMetaTests]))
14-
class VulpixMetaTests extends ParallelTesting {
15-
def maxDuration = 1.seconds
16-
// Ensure maximum reproducibility.
17-
def numberOfSlaves = 1
18-
def safeMode = false // Don't fork a new VM after each run test
19-
def isInteractive = false // Don't beautify output for interactive use.
20-
def testFilter = None // Run all the tests.
21-
def updateCheckFiles: Boolean = false
14+
class VulpixMetaTests {
15+
import VulpixMetaTests._
2216

2317
implicit val summaryReport: SummaryReporting = new SummaryReport
2418
implicit def testGroup: TestGroup = TestGroup("VulpixMetaTests")
@@ -27,3 +21,16 @@ class VulpixMetaTests extends ParallelTesting {
2721
@Test def compileNeg: Unit = compileFilesInDir("tests/vulpix-tests/meta/neg", defaultOptions).checkExpectedErrors()
2822
@Test def runAll: Unit = compileFilesInDir("tests/vulpix-tests/meta/run", defaultOptions).checkRuns()
2923
}
24+
25+
object VulpixMetaTests extends ParallelTesting {
26+
def maxDuration = 1.seconds
27+
// Ensure maximum reproducibility.
28+
def numberOfSlaves = 1
29+
def safeMode = false // Don't fork a new VM after each run test
30+
def isInteractive = false // Don't beautify output for interactive use.
31+
def testFilter = None // Run all the tests.
32+
def updateCheckFiles: Boolean = false
33+
34+
@AfterClass
35+
def tearDown() = this.cleanup()
36+
}

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

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,24 @@ package vulpix
33

44
import java.io.{File => JFile}
55
import org.junit.Assert._
6-
import org.junit.Test
6+
import org.junit.{ Test, AfterClass }
77

88
import scala.concurrent.duration._
99
import scala.util.control.NonFatal
1010

1111
/** Unit tests for the Vulpix test suite */
12-
class VulpixUnitTests extends ParallelTesting {
12+
class VulpixUnitTests {
13+
import VulpixUnitTests._
1314
import TestConfiguration._
1415

1516
implicit val _: SummaryReporting = new NoSummaryReport
1617

1718
implicit def testGroup: TestGroup = TestGroup("VulpixTests")
1819

19-
def maxDuration = 3.seconds
20-
def numberOfSlaves = 5
21-
def safeMode = sys.env.get("SAFEMODE").isDefined
22-
def isInteractive = !sys.env.contains("DRONE")
23-
def testFilter = None
24-
def updateCheckFiles: Boolean = false
25-
2620
// To fail with something else than an AssertionError
2721
def fail(): Unit = throw new Exception("didn't fail properly")
2822

29-
@Test def missingFile: Unit = if (!scala.util.Properties.isWin)
23+
@Test def missingFile: Unit =
3024
try {
3125
compileFile("tests/vulpix-tests/unit/i-dont-exist.scala", defaultOptions).expectFailure.checkExpectedErrors()
3226
fail()
@@ -64,7 +58,7 @@ class VulpixUnitTests extends ParallelTesting {
6458
@Test def runDiffOutput1: Unit =
6559
compileFile("tests/vulpix-tests/unit/runDiffOutput1.scala", defaultOptions).expectFailure.checkRuns()
6660

67-
@Test def runStackOverflow: Unit = if (!scala.util.Properties.isWin)
61+
@Test def runStackOverflow: Unit =
6862
compileFile("tests/vulpix-tests/unit/stackOverflow.scala", defaultOptions).expectFailure.checkRuns()
6963

7064
@Test def runOutRedirects: Unit =
@@ -82,15 +76,15 @@ class VulpixUnitTests extends ParallelTesting {
8276
@Test def deadlock: Unit =
8377
compileFile("tests/vulpix-tests/unit/deadlock.scala", defaultOptions).expectFailure.checkRuns()
8478

85-
@Test def badJava: Unit = if (!scala.util.Properties.isWin)
79+
@Test def badJava: Unit =
8680
try {
8781
compileFile("tests/vulpix-tests/unit/BadJava.java", defaultOptions).suppressAllOutput.checkCompile()
8882
fail()
8983
} catch {
9084
case ae: AssertionError => assertTrue(ae.getMessage.contains("java compilation failed"))
9185
}
9286

93-
@Test def runTimeout: Unit = if (!scala.util.Properties.isWin) {
87+
@Test def runTimeout: Unit = {
9488
val fileName = s"tests/vulpix-tests/unit/timeout.scala"
9589
try {
9690
compileFile(fileName, defaultOptions).checkRuns()
@@ -103,3 +97,16 @@ class VulpixUnitTests extends ParallelTesting {
10397
}
10498
}
10599
}
100+
101+
102+
object VulpixUnitTests extends ParallelTesting {
103+
def maxDuration = 3.seconds
104+
def numberOfSlaves = 5
105+
def safeMode = sys.env.get("SAFEMODE").isDefined
106+
def isInteractive = !sys.env.contains("DRONE")
107+
def testFilter = None
108+
def updateCheckFiles: Boolean = false
109+
110+
@AfterClass
111+
def tearDown() = this.cleanup()
112+
}

0 commit comments

Comments
 (0)