diff --git a/modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala b/modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala index 433d75a776..40429ca1d8 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala @@ -67,16 +67,14 @@ abstract class RunTestDefinitions(val scalaVersionOpt: Option[String]) } } - if (TestUtil.canRunJs) { - test("simple script JS") { - simpleJsTest() - } - test("simple script JS in release mode") { - simpleJsTest("--js-mode", "release") - } + test("simple script JS") { + simpleJsTest() + } + test("simple script JS in release mode") { + simpleJsTest("--js-mode", "release") } - def simpleJsViaConfigFileTest(): Unit = { + test("simple script JS via config file") { val message = "Hello" val inputs = TestInputs( Seq( @@ -95,11 +93,6 @@ abstract class RunTestDefinitions(val scalaVersionOpt: Option[String]) } } - if (TestUtil.canRunJs) - test("simple script JS via config file") { - simpleJsViaConfigFileTest() - } - def platformNl = if (Properties.isWin) "\\r\\n" else "\\n" def canRunScWithNative(): Boolean = @@ -208,7 +201,7 @@ abstract class RunTestDefinitions(val scalaVersionOpt: Option[String]) } } - def multipleScriptsJs(): Unit = { + test("Multiple scripts JS") { val message = "Hello" val inputs = TestInputs( Seq( @@ -229,11 +222,6 @@ abstract class RunTestDefinitions(val scalaVersionOpt: Option[String]) } } - if (TestUtil.canRunJs) - test("Multiple scripts JS") { - multipleScriptsJs() - } - def multipleScriptsNative(): Unit = { val message = "Hello" val inputs = TestInputs( @@ -347,7 +335,7 @@ abstract class RunTestDefinitions(val scalaVersionOpt: Option[String]) passArgumentsScala3() } - def directoryJs(): Unit = { + test("Directory JS") { val message = "Hello" val inputs = TestInputs( Seq( @@ -369,11 +357,6 @@ abstract class RunTestDefinitions(val scalaVersionOpt: Option[String]) } } - if (TestUtil.canRunJs) - test("Directory JS") { - directoryJs() - } - def directoryNative(): Unit = { val message = "Hello" val inputs = TestInputs( diff --git a/modules/integration/src/test/scala/scala/cli/integration/TestTestDefinitions.scala b/modules/integration/src/test/scala/scala/cli/integration/TestTestDefinitions.scala index 1a8d863d9f..7069225f09 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/TestTestDefinitions.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/TestTestDefinitions.scala @@ -177,18 +177,14 @@ abstract class TestTestDefinitions(val scalaVersionOpt: Option[String]) } } - def successfulJsTest(): Unit = + test("successful test JS") { successfulTestInputs.fromRoot { root => val output = os.proc(TestUtil.cli, "test", extraOptions, ".", "--js") .call(cwd = root) .out.text() expect(output.contains("Hello from tests")) } - - if (TestUtil.canRunJs) - test("successful test JS") { - successfulJsTest() - } + } def successfulNativeTest(): Unit = successfulTestInputs.fromRoot { root => @@ -212,18 +208,14 @@ abstract class TestTestDefinitions(val scalaVersionOpt: Option[String]) } } - def failingJsTest(): Unit = + test("failing test JS") { failingTestInputs.fromRoot { root => val output = os.proc(TestUtil.cli, "test", extraOptions, ".", "--js") .call(cwd = root, check = false) .out.text() expect(output.contains("Hello from tests")) } - - if (TestUtil.canRunJs) - test("failing test JS") { - failingJsTest() - } + } def failingNativeTest(): Unit = failingTestInputs.fromRoot { root => @@ -257,18 +249,14 @@ abstract class TestTestDefinitions(val scalaVersionOpt: Option[String]) } } - def utestJs(): Unit = + test("utest JS") { successfulUtestJsInputs.fromRoot { root => val output = os.proc(TestUtil.cli, "test", extraOptions, ".", "--js") .call(cwd = root) .out.text() expect(output.contains("Hello from tests")) } - - if (TestUtil.canRunJs) - test("utest JS") { - utestJs() - } + } def utestNative(): Unit = successfulUtestNativeInputs.fromRoot { root => @@ -314,7 +302,7 @@ abstract class TestTestDefinitions(val scalaVersionOpt: Option[String]) } val platforms = { - val maybeJs = if (TestUtil.canRunJs) Seq("JS" -> Seq("--js")) else Nil + val maybeJs = Seq("JS" -> Seq("--js")) val maybeNative = if (TestUtil.canRunNative && actualScalaVersion.startsWith("2.")) Seq("Native" -> Seq("--native")) @@ -453,9 +441,7 @@ abstract class TestTestDefinitions(val scalaVersionOpt: Option[String]) test("Cross-tests") { val supportsNative = TestUtil.canRunNative && actualScalaVersion.startsWith("2.") val platforms = { - var pf = Seq("\"jvm\"") - if (TestUtil.canRunJs) - pf = pf :+ "\"js\"" + var pf = Seq("\"jvm\"", "\"js\"") if (supportsNative) pf = pf :+ "\"native\"" pf.mkString(", ") @@ -481,11 +467,7 @@ abstract class TestTestDefinitions(val scalaVersionOpt: Option[String]) | println("Hello from " + "jvm") | } |} - |""".stripMargin - ) - ) - if (TestUtil.canRunJs) - inputs0 = inputs0.add( + |""".stripMargin, os.rel / "MyJsTests.scala" -> """//> using target.platform "js" | @@ -496,6 +478,7 @@ abstract class TestTestDefinitions(val scalaVersionOpt: Option[String]) |} |""".stripMargin ) + ) if (supportsNative) inputs0 = inputs0.add( os.rel / "MyNativeTests.scala" -> @@ -513,11 +496,10 @@ abstract class TestTestDefinitions(val scalaVersionOpt: Option[String]) inputs.fromRoot { root => val res = os.proc(TestUtil.cli, "test", extraOptions, ".", "--cross").call(cwd = root) val output = res.out.text() - val expectedCount = 1 + (if (TestUtil.canRunJs) 1 else 0) + (if (supportsNative) 1 else 0) + val expectedCount = 2 + (if (supportsNative) 1 else 0) expect(countSubStrings(output, "Hello from shared") == expectedCount) expect(output.contains("Hello from jvm")) - if (TestUtil.canRunJs) - expect(output.contains("Hello from js")) + expect(output.contains("Hello from js")) if (supportsNative) expect(output.contains("Hello from native")) } diff --git a/modules/integration/src/test/scala/scala/cli/integration/TestUtil.scala b/modules/integration/src/test/scala/scala/cli/integration/TestUtil.scala index a2bf26dfc2..0148417f4c 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/TestUtil.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/TestUtil.scala @@ -29,7 +29,6 @@ object TestUtil { ) // format: on - lazy val canRunJs = true lazy val canRunNative = true def fromPath(app: String): Option[String] = {