Skip to content

Commit 8ed39c1

Browse files
committed
Fix integration tests running on wrong Scala versions
1 parent 2385c39 commit 8ed39c1

File tree

2 files changed

+48
-46
lines changed

2 files changed

+48
-46
lines changed

modules/integration/src/test/scala/scala/cli/integration/RunScalaJsTestDefinitions.scala

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -441,31 +441,32 @@ trait RunScalaJsTestDefinitions { _: RunTestDefinitions =>
441441
}
442442
}
443443

444-
test("js defaults & toolkit default") {
445-
val msg = "Hello"
446-
TestInputs(
447-
os.rel / "toolkit.scala" ->
448-
s"""//> using toolkit default
449-
|//> using toolkit typelevel:default
450-
|
451-
|//> using platform "scala-js"
452-
|
453-
|import cats.effect.*
454-
|import scala.scalajs.js
455-
|
456-
|object Hello extends IOApp.Simple {
457-
|
458-
| def run = IO {
459-
| val console = js.Dynamic.global.console
460-
| val jsonString = "{\\"msg\\": \\"$msg\\"}"
461-
| val json: ujson.Value = ujson.read(jsonString)
462-
| console.log(json("msg").str)
463-
| }
464-
|}
465-
|""".stripMargin
466-
).fromRoot { root =>
467-
val result = os.proc(TestUtil.cli, "run", "toolkit.scala").call(cwd = root)
468-
expect(result.out.trim() == msg)
444+
if (!actualScalaVersion.startsWith("2.12"))
445+
test("js defaults & toolkit default") {
446+
val msg = "Hello"
447+
TestInputs(
448+
os.rel / "toolkit.scala" ->
449+
s"""//> using toolkit default
450+
|//> using toolkit typelevel:default
451+
|
452+
|//> using platform "scala-js"
453+
|
454+
|import cats.effect._
455+
|import scala.scalajs.js
456+
|
457+
|object Hello extends IOApp.Simple {
458+
|
459+
| def run = IO {
460+
| val console = js.Dynamic.global.console
461+
| val jsonString = "{\\"msg\\": \\"$msg\\"}"
462+
| val json: ujson.Value = ujson.read(jsonString)
463+
| console.log(json("msg").str)
464+
| }
465+
|}
466+
|""".stripMargin
467+
).fromRoot { root =>
468+
val result = os.proc(TestUtil.cli, "run", "toolkit.scala", extraOptions).call(cwd = root)
469+
expect(result.out.trim() == msg)
470+
}
469471
}
470-
}
471472
}

modules/integration/src/test/scala/scala/cli/integration/RunScalaNativeTestDefinitions.scala

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -290,34 +290,35 @@ trait RunScalaNativeTestDefinitions { _: RunTestDefinitions =>
290290
val configEnv = Map("SCALA_CLI_CONFIG" -> (configDir / "config.json").toString)
291291
os.proc(TestUtil.cli, "config", "interactive", "true")
292292
.call(cwd = root, env = configEnv)
293-
val output1 = os.proc(TestUtil.cli, "run", "--native", ".")
293+
val output1 = os.proc(TestUtil.cli, "run", "--native", ".", extraOptions)
294294
.call(cwd = root, env = configEnv ++ Seq("SCALA_CLI_INTERACTIVE_INPUTS" -> "foo.Main1"))
295295
.out.lines().last
296296
expect(output1 == "Hello from Main1")
297-
val output2 = os.proc(TestUtil.cli, "run", "--native", ".")
297+
val output2 = os.proc(TestUtil.cli, "run", "--native", ".", extraOptions)
298298
.call(cwd = root, env = configEnv ++ Seq("SCALA_CLI_INTERACTIVE_INPUTS" -> "foo.Main2"))
299299
.out.lines().last
300300
expect(output2 == "Hello from Main2")
301301
}
302302
}
303303

304-
test("native defaults & toolkit default") {
305-
TestInputs(
306-
os.rel / "toolkit.scala" ->
307-
"""//> using toolkit default
308-
|//> using toolkit typelevel:default
309-
|
310-
|//> using platform native
311-
|
312-
|import cats.effect.*
313-
|
314-
|object Hello extends IOApp.Simple {
315-
| def run = IO.println(os.pwd)
316-
|}
317-
|""".stripMargin
318-
).fromRoot { root =>
319-
val result = os.proc(TestUtil.cli, "run", "toolkit.scala").call(cwd = root)
320-
expect(result.out.trim() == root.toString)
304+
if (!actualScalaVersion.startsWith("2.12"))
305+
test("native defaults & toolkit default") {
306+
TestInputs(
307+
os.rel / "toolkit.scala" ->
308+
"""//> using toolkit default
309+
|//> using toolkit typelevel:default
310+
|
311+
|//> using platform native
312+
|
313+
|import cats.effect._
314+
|
315+
|object Hello extends IOApp.Simple {
316+
| def run = IO.println(os.pwd)
317+
|}
318+
|""".stripMargin
319+
).fromRoot { root =>
320+
val result = os.proc(TestUtil.cli, "run", "toolkit.scala", extraOptions).call(cwd = root)
321+
expect(result.out.trim() == root.toString)
322+
}
321323
}
322-
}
323324
}

0 commit comments

Comments
 (0)