Skip to content

Commit 0c5a25c

Browse files
committed
Add REPL exit test to BashExitCodeTests
1 parent 4661104 commit 0c5a25c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

compiler/test/dotty/tools/scripting/BashExitCodeTests.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ class BashExitCodeTests:
3232
s"expected $expectedExitCode but got $exitCode${pp("out", stdout)}${pp("err", stderr)}"
3333
}, expectedExitCode, exitCode)
3434

35-
// Helpers for running scala, scalac, and scalac without the output directory ("raw")
35+
// Helpers for running scala, scalac, scalac, and repl without the output directory ("raw")
3636
def scala(args: String*) = verifyExit(scalaPath, ("--power" +: args :+ "--offline" :+ "--server=false")*)
3737
def scalacRaw(args: String*) = verifyExit(scalacPath, args*)
3838
def scalac(args: String*) = scalacRaw(("-d" +: tmpDir +: args)*)
39+
def repl(args: String*) = verifyExit(replPath, args*)
3940

4041
/** The path to the test file for this class. */
4142
def f(body: String, suffix: String = ".scala"): String =
@@ -72,6 +73,8 @@ class BashExitCodeTests:
7273
@Test def xPluginList = scala("-Xplugin-list")(0)
7374
@Test def vPhases = scala("-Vphases")(0)
7475

76+
@Test def replEval = repl("--repl-eval", "--repl-init-script", "println(\"Hello from init script!\"); val i = 2 * 2")(0)
77+
7578
/** A utility for running two commands in a row, like you do in bash. */
7679
extension (inline u1: Unit) inline def & (inline u2: Unit): Unit = { u1; u2 }
7780
end BashExitCodeTests

compiler/test/dotty/tools/scripting/ScriptTestEnv.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,11 @@ object ScriptTestEnv {
292292

293293
lazy val cwd: Path = Paths.get(".").toAbsolutePath.normalize
294294

295-
lazy val (scalacPath: String, scalaPath: String) = {
295+
lazy val (scalacPath: String, scalaPath: String, replPath: String) = {
296296
val scalac = s"$workingDirectory/$packBinDir/scalac".toPath.normalize
297297
val scala = s"$workingDirectory/$packBinDir/scala".toPath.normalize
298-
(scalac.norm, scala.norm)
298+
val repl = s"$workingDirectory/$packBinDir/repl".toPath.normalize
299+
(scalac.norm, scala.norm, repl.norm)
299300
}
300301

301302

0 commit comments

Comments
 (0)