Skip to content

Commit 0a1995f

Browse files
committed
Only instantiate tests that we'll run
As we add more variables to the test matrix, assuming the unneeded ones away becomes too cumbersome.
1 parent f0dc9bd commit 0a1995f

File tree

5 files changed

+25
-28
lines changed

5 files changed

+25
-28
lines changed

js-envs-test-kit/src/main/scala/org/scalajs/jsenv/test/ComTests.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
package org.scalajs.jsenv.test
1414

15-
import org.junit.{Before, Test, AssumptionViolatedException}
15+
import org.junit.{Test, AssumptionViolatedException}
1616
import org.junit.Assume._
1717

1818
import org.scalajs.jsenv._
@@ -21,11 +21,6 @@ import org.scalajs.jsenv.test.kit.TestKit
2121
private[test] class ComTests(config: JSEnvSuiteConfig) {
2222
private val kit = new TestKit(config.jsEnv, config.awaitTimeout)
2323

24-
@Before
25-
def before: Unit = {
26-
assumeTrue("JSEnv needs com support", config.supportsCom)
27-
}
28-
2924
@Test
3025
def basicTest: Unit = {
3126
kit.withComRun("""

js-envs-test-kit/src/main/scala/org/scalajs/jsenv/test/JSEnvSuite.scala

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,26 @@ private object JSEnvSuiteRunner {
6767
private def getRunners(config: JSEnvSuiteConfig): java.util.List[Runner] = {
6868
import java.lang.Boolean.{TRUE, FALSE}
6969

70-
java.util.Arrays.asList(
71-
r[RunTests](config, "withCom" -> FALSE),
72-
r[RunTests](config, "withCom" -> TRUE),
73-
r[TimeoutRunTests](config, "withCom" -> FALSE),
74-
r[TimeoutRunTests](config, "withCom" -> TRUE),
75-
r[ComTests](config),
76-
r[TimeoutComTests](config)
77-
)
70+
val runners = new java.util.ArrayList[Runner]
71+
72+
val withComValues =
73+
if (config.supportsCom) List(TRUE, FALSE)
74+
else List(TRUE, FALSE)
75+
76+
for (withCom <- withComValues)
77+
runners.add(r[RunTests](config, "withCom" -> withCom))
78+
79+
if (config.supportsTimeout) {
80+
for (withCom <- withComValues)
81+
runners.add(r[TimeoutRunTests](config, "withCom" -> withCom))
82+
}
83+
84+
if (config.supportsCom)
85+
runners.add(r[ComTests](config))
86+
87+
if (config.supportsTimeout)
88+
runners.add(r[TimeoutComTests](config))
89+
90+
runners
7891
}
7992
}

js-envs-test-kit/src/main/scala/org/scalajs/jsenv/test/RunTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import java.nio.file.Files
1919
import com.google.common.jimfs.Jimfs
2020

2121
import org.junit.Assume._
22-
import org.junit.{Test, Before, AssumptionViolatedException}
22+
import org.junit.{Test, AssumptionViolatedException}
2323

2424
import org.scalajs.jsenv._
2525
import org.scalajs.jsenv.test.kit.{TestKit, Run}

js-envs-test-kit/src/main/scala/org/scalajs/jsenv/test/TimeoutComTests.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ package org.scalajs.jsenv.test
1414

1515
import scala.concurrent.duration._
1616

17-
import org.junit.{Before, Test}
17+
import org.junit.Test
1818
import org.junit.Assert._
1919
import org.junit.Assume._
2020

@@ -24,12 +24,6 @@ import org.scalajs.jsenv.test.kit.TestKit
2424
private[test] class TimeoutComTests(config: JSEnvSuiteConfig) {
2525
private val kit = new TestKit(config.jsEnv, config.awaitTimeout)
2626

27-
@Before
28-
def before: Unit = {
29-
assumeTrue("JSEnv needs timeout support", config.supportsTimeout)
30-
assumeTrue("JSEnv needs com support", config.supportsCom)
31-
}
32-
3327
/** Slack for timeout tests (see #3457)
3428
*
3529
* Empirically we can observe that timing can be off by ~0.1ms. By cutting

js-envs-test-kit/src/main/scala/org/scalajs/jsenv/test/TimeoutRunTests.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ package org.scalajs.jsenv.test
1414

1515
import scala.concurrent.duration._
1616

17-
import org.junit.{Before, Test}
17+
import org.junit.Test
1818
import org.junit.Assert._
1919
import org.junit.Assume._
2020

@@ -29,11 +29,6 @@ private[test] class TimeoutRunTests(config: JSEnvSuiteConfig, withCom: Boolean)
2929
else kit.withRun(input)(body)
3030
}
3131

32-
@Before
33-
def before: Unit = {
34-
assumeTrue("JSEnv needs timeout support", config.supportsTimeout)
35-
}
36-
3732
/** Slack for timeout tests (see #3457)
3833
*
3934
* Empirically we can observe that timing can be off by ~0.1ms. By cutting

0 commit comments

Comments
 (0)