Skip to content

Commit

Permalink
Add REPL exit test to BashExitCodeTests
Browse files Browse the repository at this point in the history
  • Loading branch information
noti0na1 committed Feb 21, 2025
1 parent 4661104 commit 0c5a25c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion compiler/test/dotty/tools/scripting/BashExitCodeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ class BashExitCodeTests:
s"expected $expectedExitCode but got $exitCode${pp("out", stdout)}${pp("err", stderr)}"
}, expectedExitCode, exitCode)

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

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

@Test def replEval = repl("--repl-eval", "--repl-init-script", "println(\"Hello from init script!\"); val i = 2 * 2")(0)

/** A utility for running two commands in a row, like you do in bash. */
extension (inline u1: Unit) inline def & (inline u2: Unit): Unit = { u1; u2 }
end BashExitCodeTests
5 changes: 3 additions & 2 deletions compiler/test/dotty/tools/scripting/ScriptTestEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,11 @@ object ScriptTestEnv {

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

lazy val (scalacPath: String, scalaPath: String) = {
lazy val (scalacPath: String, scalaPath: String, replPath: String) = {
val scalac = s"$workingDirectory/$packBinDir/scalac".toPath.normalize
val scala = s"$workingDirectory/$packBinDir/scala".toPath.normalize
(scalac.norm, scala.norm)
val repl = s"$workingDirectory/$packBinDir/repl".toPath.normalize
(scalac.norm, scala.norm, repl.norm)
}


Expand Down

0 comments on commit 0c5a25c

Please sign in to comment.