forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScalaJSCompilationTests.scala
70 lines (56 loc) · 2.33 KB
/
ScalaJSCompilationTests.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package dotty
package tools
package dotc
import org.junit.{ Test, BeforeClass, AfterClass }
import org.junit.experimental.categories.Category
import scala.concurrent.duration._
import reporting.TestReporter
import vulpix._
@Category(Array(classOf[ScalaJSCompilationTests]))
class ScalaJSCompilationTests extends ParallelTesting {
import ParallelTesting._
import TestConfiguration._
import ScalaJSCompilationTests._
import CompilationTest.aggregateTests
// Test suite configuration --------------------------------------------------
def maxDuration = 60.seconds
def numberOfSlaves = 5
def safeMode = Properties.testsSafeMode
def isInteractive = SummaryReport.isInteractive
def testFilter = Properties.testsFilter
def updateCheckFiles: Boolean = Properties.testsUpdateCheckfile
def failedTests = TestReporter.lastRunFailedTests
// Negative tests ------------------------------------------------------------
@Test def negScalaJS: Unit = {
implicit val testGroup: TestGroup = TestGroup("negScalaJS")
aggregateTests(
compileFilesInDir("tests/neg-scalajs", scalaJSOptions),
).checkExpectedErrors()
}
// Run tests -----------------------------------------------------------------
override protected def shouldSkipTestSource(testSource: TestSource): Boolean =
testSource.allToolArgs.get(ToolName.ScalaJS).exists(_.contains("--skip"))
override def runMain(classPath: String, toolArgs: ToolArgs)(implicit summaryReport: SummaryReporting): Status =
import scala.concurrent.ExecutionContext.Implicits.global
val scalaJSOptions = toolArgs.getOrElse(ToolName.ScalaJS, Nil)
try
val useCompliantSemantics = scalaJSOptions.contains("--compliant-semantics")
val sjsCode = ScalaJSLink.link(classPath, useCompliantSemantics)
JSRun.runJSCode(sjsCode)
catch
case t: Exception =>
val writer = new java.io.StringWriter()
t.printStackTrace(new java.io.PrintWriter(writer))
Failure(writer.toString())
end runMain
@Test def runScalaJS: Unit = {
implicit val testGroup: TestGroup = TestGroup("runScalaJS")
aggregateTests(
compileFilesInDir("tests/run", scalaJSOptions),
).checkRuns()
}
}
object ScalaJSCompilationTests {
implicit val summaryReport: SummaryReporting = new SummaryReport
@AfterClass def cleanup(): Unit = summaryReport.echoSummary()
}