New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSEnv fixes #3413

Merged
merged 3 commits into from Jul 21, 2018
Jump to file or symbol
Failed to load files and symbols.
+13 −15
Diff settings

Always

Just for now

Next

Fix #3410: Add supportsExit to JSEnvSuiteConfig.

We also remove terminateVMJSCode. This is a source breaking
change. However, leaving withTerminateVMJSCode would not relieve any
burden of sub-projects as the Suite would fail anyways.
  • Loading branch information...
gzm0 committed Jul 21, 2018
commit 6746cf3a20d2497bbc6c520666a47f7ec1cd28dd
@@ -38,10 +38,10 @@ private[test] class ComTests(config: JSEnvSuiteConfig) {
@Test
def jsExitsOnMessageTest: Unit = {
assumeTrue(config.terminateVMJSCode.isDefined)
assumeTrue(config.supportsExit)
val run = kit.start(s"""
scalajsCom.init(function(msg) { ${config.terminateVMJSCode.get}; });
val run = kit.start("""
scalajsCom.init(function(msg) { __ScalaJSEnv.exitFunction(0); });
for (var i = 0; i < 10; ++i)
scalajsCom.send("msg: " + i);
""", RunConfig())
@@ -26,23 +26,23 @@ import scala.concurrent.duration._
*/
final class JSEnvSuiteConfig private (
val jsEnv: JSEnv,
val terminateVMJSCode: Option[String],
val supportsExit: Boolean,
val supportsCom: Boolean,
val supportsTimeout: Boolean,
val awaitTimeout: FiniteDuration,
val description: String
) {
private def this(jsEnv: JSEnv) = this(
jsEnv = jsEnv,
terminateVMJSCode = None,
supportsExit = true,
supportsCom = true,
supportsTimeout = true,
awaitTimeout = 1.minute,
description = jsEnv.name
)
def withTerminateVMJSCode(code: String): JSEnvSuiteConfig =
copy(terminateVMJSCode = Some(code))
def withSupportsExit(supportsExit: Boolean): JSEnvSuiteConfig =
copy(supportsExit = supportsExit)
def withSupportsCom(supportsCom: Boolean): JSEnvSuiteConfig =
copy(supportsCom = supportsCom)
@@ -56,12 +56,13 @@ final class JSEnvSuiteConfig private (
def withDescription(description: String): JSEnvSuiteConfig =
copy(description = description)
private def copy(terminateVMJSCode: Option[String] = terminateVMJSCode,
private def copy(
supportsExit: Boolean = supportsExit,
supportsCom: Boolean = supportsCom,
supportsTimeout: Boolean = supportsTimeout,
awaitTimeout: FiniteDuration = awaitTimeout,
description: String = description) = {
new JSEnvSuiteConfig(jsEnv, terminateVMJSCode, supportsCom,
new JSEnvSuiteConfig(jsEnv, supportsExit, supportsCom,
supportsTimeout, awaitTimeout, description)
}
}
@@ -44,9 +44,9 @@ private[test] class RunTests(config: JSEnvSuiteConfig, withCom: Boolean) {
@Test
def jsExitsTest: Unit = {
assumeTrue(config.terminateVMJSCode.isDefined)
assumeTrue(config.supportsExit)
val run = kit.start(config.terminateVMJSCode.get, RunConfig())
val run = kit.start("__ScalaJSEnv.exitFunction(0);", RunConfig())
try {
Await.result(run.future, config.awaitTimeout)
} finally {
@@ -5,7 +5,4 @@ import org.scalajs.jsenv.test._
import org.junit.runner.RunWith
@RunWith(classOf[JSEnvSuiteRunner])
class NodeJSSuite extends JSEnvSuite(
JSEnvSuiteConfig(new NodeJSEnv)
.withTerminateVMJSCode("process.exit(0)")
)
class NodeJSSuite extends JSEnvSuite(JSEnvSuiteConfig(new NodeJSEnv))
ProTip! Use n and p to navigate between commits in a pull request.