Skip to content

Commit

Permalink
Merge pull request #1134 from alexarchambault/two-step-startup
Browse files Browse the repository at this point in the history
Tweak two-step startup
  • Loading branch information
alexarchambault authored Jun 1, 2023
2 parents b990f60 + d636221 commit a358632
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class KernelTestsTwoStepStartup extends munit.FunSuite {
val kernelLauncher = new KernelLauncher(isTwoStepStartup = true, "2.13.10")

test("Directives and code in first cell 3") {
kernelLauncher.withKernel { implicit runner =>
kernelLauncher.withKernel { runner =>
implicit val sessionId: SessionId = SessionId()
runner.withSession() { implicit session =>
execute(
Expand All @@ -24,7 +24,7 @@ class KernelTestsTwoStepStartup extends munit.FunSuite {
}

test("Directives and code in first cell 213") {
kernelLauncher.withKernel { implicit runner =>
kernelLauncher.withKernel { runner =>
implicit val sessionId: SessionId = SessionId()
runner.withSession() { implicit session =>
execute(
Expand All @@ -38,7 +38,7 @@ class KernelTestsTwoStepStartup extends munit.FunSuite {
}

test("Directives and code in first cell 212") {
kernelLauncher.withKernel { implicit runner =>
kernelLauncher.withKernel { runner =>
implicit val sessionId: SessionId = SessionId()
runner.withSession() { implicit session =>
execute(
Expand All @@ -52,7 +52,7 @@ class KernelTestsTwoStepStartup extends munit.FunSuite {
}

test("Directives and code in first cell short 213") {
kernelLauncher.withKernel { implicit runner =>
kernelLauncher.withKernel { runner =>
implicit val sessionId: SessionId = SessionId()
runner.withSession() { implicit session =>
execute(
Expand All @@ -66,7 +66,7 @@ class KernelTestsTwoStepStartup extends munit.FunSuite {
}

test("Directives and code in first cell short 212") {
kernelLauncher.withKernel { implicit runner =>
kernelLauncher.withKernel { runner =>
implicit val sessionId: SessionId = SessionId()
runner.withSession() { implicit session =>
execute(
Expand All @@ -80,7 +80,7 @@ class KernelTestsTwoStepStartup extends munit.FunSuite {
}

test("Several directives and comments") {
kernelLauncher.withKernel { implicit runner =>
kernelLauncher.withKernel { runner =>
implicit val sessionId: SessionId = SessionId()
runner.withSession() { implicit session =>
execute(
Expand All @@ -99,4 +99,17 @@ class KernelTestsTwoStepStartup extends munit.FunSuite {
}
}

test("Java option on command-line") {
kernelLauncher.withKernel { runner =>
implicit val sessionId: SessionId = SessionId()
runner.withSession("--java-opt", "-Dfoo=thing") { implicit session =>
execute(
"""//> using scala "3.2.2"
|val foo = sys.props("foo")""".stripMargin,
"""foo: String = "thing""""
)
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,16 @@ object Launcher extends CaseApp[LauncherOptions] {
"java"
}

val javaOptions = options.javaOpt ++ params0.javaOptions

val memOptions =
if (params0.javaOptions.exists(_.startsWith("-Xmx"))) Nil
if (javaOptions.exists(_.startsWith("-Xmx"))) Nil
else Seq("-Xmx512m")

val proc = os.proc(
javaCommand,
memOptions,
params0.javaOptions,
javaOptions,
"-cp",
(options.extraStartupClassPath :+ launcher.toString)
.filter(_.nonEmpty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ final case class LauncherOptions(
predef: List[String] = Nil,
extraStartupClassPath: List[String] = Nil,
sharedDependencies: List[String] = Nil,
compileOnly: Option[Boolean] = None
compileOnly: Option[Boolean] = None,
javaOpt: List[String] = Nil
) {
// format: on

Expand Down

0 comments on commit a358632

Please sign in to comment.