From 454000d02d28e826c83d3639aab0439bcbd23fbf Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Thu, 1 Jun 2023 14:36:57 +0200 Subject: [PATCH 1/2] NIT --- .../integration/KernelTestsTwoStepStartup.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup.scala b/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup.scala index 75e57b6f1..2145d140b 100644 --- a/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup.scala +++ b/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup.scala @@ -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( @@ -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( @@ -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( @@ -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( @@ -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( @@ -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( From d636221891fa420ab12116edce38231c2844cdec Mon Sep 17 00:00:00 2001 From: Alex Archambault Date: Thu, 1 Jun 2023 14:44:09 +0200 Subject: [PATCH 2/2] Add --java-opt option to launcher --- .../integration/KernelTestsTwoStepStartup.scala | 13 +++++++++++++ .../src/main/scala/almond/launcher/Launcher.scala | 6 ++++-- .../scala/almond/launcher/LauncherOptions.scala | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup.scala b/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup.scala index 2145d140b..4664b4140 100644 --- a/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup.scala +++ b/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup.scala @@ -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"""" + ) + } + } + } + } diff --git a/modules/scala/launcher/src/main/scala/almond/launcher/Launcher.scala b/modules/scala/launcher/src/main/scala/almond/launcher/Launcher.scala index b692d8cc6..1a22dc260 100644 --- a/modules/scala/launcher/src/main/scala/almond/launcher/Launcher.scala +++ b/modules/scala/launcher/src/main/scala/almond/launcher/Launcher.scala @@ -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) diff --git a/modules/scala/launcher/src/main/scala/almond/launcher/LauncherOptions.scala b/modules/scala/launcher/src/main/scala/almond/launcher/LauncherOptions.scala index 690e7d5ae..0fd666681 100644 --- a/modules/scala/launcher/src/main/scala/almond/launcher/LauncherOptions.scala +++ b/modules/scala/launcher/src/main/scala/almond/launcher/LauncherOptions.scala @@ -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