diff --git a/examples/plotly-scala.ipynb b/examples/plotly-scala.ipynb index b5ecd6113..3f2ff166a 100644 --- a/examples/plotly-scala.ipynb +++ b/examples/plotly-scala.ipynb @@ -19,8 +19,7 @@ { "data": { "text/plain": [ - "\u001b[32mimport \u001b[39m\u001b[36m$ivy.$ \n", - "\u001b[39m\n", + "\u001b[32mimport \u001b[39m\u001b[36m$ivy.$\u001b[39m\n", "\u001b[32mimport \u001b[39m\u001b[36mplotly._, plotly.element._, plotly.layout._, plotly.Almond._\n", "\n", "// if you want to have the plots available without an internet connection:\n", diff --git a/examples/scalapy-displays.ipynb b/examples/scalapy-displays.ipynb index cdb8ac631..17439f85f 100644 --- a/examples/scalapy-displays.ipynb +++ b/examples/scalapy-displays.ipynb @@ -10,11 +10,8 @@ { "data": { "text/plain": [ - "\u001b[32mimport \u001b[39m\u001b[36m$ivy.$ \n", - "\u001b[39m\n", - "\u001b[32mimport \u001b[39m\u001b[36mai.kien.python.Python\n", - "\n", - "\u001b[39m" + "\u001b[32mimport \u001b[39m\u001b[36m$ivy.$\u001b[39m\n", + "\u001b[32mimport \u001b[39m\u001b[36mai.kien.python.Python\u001b[39m" ] }, "execution_count": 1, @@ -44,12 +41,9 @@ { "data": { "text/plain": [ - "\u001b[32mimport \u001b[39m\u001b[36m$ivy.$ \n", - "\u001b[39m\n", - "\u001b[32mimport \u001b[39m\u001b[36mme.shadaj.scalapy.py\n", - "\u001b[39m\n", - "\u001b[32mimport \u001b[39m\u001b[36mme.shadaj.scalapy.py.PyQuote\n", - "\u001b[39m\n", + "\u001b[32mimport \u001b[39m\u001b[36m$ivy.$\u001b[39m\n", + "\u001b[32mimport \u001b[39m\u001b[36mme.shadaj.scalapy.py\u001b[39m\n", + "\u001b[32mimport \u001b[39m\u001b[36mme.shadaj.scalapy.py.PyQuote\u001b[39m\n", "\u001b[32mimport \u001b[39m\u001b[36mme.shadaj.scalapy.py.SeqConverters\u001b[39m" ] }, diff --git a/modules/scala/integration/src/main/scala/almond/integration/KernelTestsDefinitions.scala b/modules/scala/integration/src/main/scala/almond/integration/KernelTestsDefinitions.scala index d1b9b403c..030e492d7 100644 --- a/modules/scala/integration/src/main/scala/almond/integration/KernelTestsDefinitions.scala +++ b/modules/scala/integration/src/main/scala/almond/integration/KernelTestsDefinitions.scala @@ -120,14 +120,14 @@ abstract class KernelTestsDefinitions extends AlmondFunSuite { test("add dependency") { kernelLauncher.withKernel { implicit runner => implicit val sessionId: SessionId = SessionId() - almond.integration.Tests.addDependency() + almond.integration.Tests.addDependency(kernelLauncher.defaultScalaVersion) } } test("add repository") { kernelLauncher.withKernel { implicit runner => implicit val sessionId: SessionId = SessionId() - almond.integration.Tests.addRepository() + almond.integration.Tests.addRepository(kernelLauncher.defaultScalaVersion) } } diff --git a/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup213.scala b/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup213.scala index 05b245f75..c4b8ba50b 100644 --- a/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup213.scala +++ b/modules/scala/integration/src/test/scala/almond/integration/KernelTestsTwoStepStartup213.scala @@ -28,7 +28,7 @@ class KernelTestsTwoStepStartup213 extends KernelTestsDefinitions { |""".stripMargin, expectError = true, stderr = - """cell2.sc:4: method foo in class Helper is deprecated + """cell2.sc:6: method foo in class Helper is deprecated |val res2_1 = foo() | ^ |No warnings can be incurred under -Werror. @@ -90,7 +90,7 @@ class KernelTestsTwoStepStartup213 extends KernelTestsDefinitions { |""".stripMargin, expectError = true, stderr = - """cell1.sc:4: method foo in class Helper is deprecated + """cell1.sc:7: method foo in class Helper is deprecated |val res1_1 = foo() | ^ |No warnings can be incurred under -Werror. @@ -125,7 +125,7 @@ class KernelTestsTwoStepStartup213 extends KernelTestsDefinitions { |""".stripMargin, expectError = true, stderr = - """cell2.sc:4: method foo in class Helper is deprecated + """cell2.sc:6: method foo in class Helper is deprecated |val res2_1 = foo() | ^ |No warnings can be incurred under -Xfatal-warnings. @@ -160,7 +160,7 @@ class KernelTestsTwoStepStartup213 extends KernelTestsDefinitions { |""".stripMargin, expectError = true, stderr = - """cell2.sc:4: method foo in class Helper is deprecated + """cell2.sc:6: method foo in class Helper is deprecated |val res2_1 = foo() | ^ |No warnings can be incurred under -Xfatal-warnings. diff --git a/modules/scala/scala-interpreter/src/test/scala/almond/ScalaKernelTests.scala b/modules/scala/scala-interpreter/src/test/scala/almond/ScalaKernelTests.scala index bb630c9d0..c7d56abad 100644 --- a/modules/scala/scala-interpreter/src/test/scala/almond/ScalaKernelTests.scala +++ b/modules/scala/scala-interpreter/src/test/scala/almond/ScalaKernelTests.scala @@ -619,7 +619,10 @@ object ScalaKernelTests extends TestSuite { val suffix = if (transitive) " --transitive" else "" kernel.execute( s"%AddDeps com.github.alexarchambault scalacheck-shapeless_1.16_$sbv 1.3.1" + suffix, - "import $ivy.$ " + maybePostImportNewLine, + if (TestUtil.isScala2) + "import $ivy.$" + else + "import $ivy.$ " + maybePostImportNewLine, ignoreStreams = true // ignoring coursier messages (that it prints when downloading things) ) kernel.execute( diff --git a/modules/scala/test-definitions/src/main/scala/almond/integration/Tests.scala b/modules/scala/test-definitions/src/main/scala/almond/integration/Tests.scala index e12136c46..315b15830 100644 --- a/modules/scala/test-definitions/src/main/scala/almond/integration/Tests.scala +++ b/modules/scala/test-definitions/src/main/scala/almond/integration/Tests.scala @@ -263,6 +263,8 @@ object Tests { ): Unit = runner.withSession("--toree-magics") { implicit session => + val isScala2 = scalaVersion.startsWith("2.") + val jar = coursierapi.Fetch.create() .addDependencies(coursierapi.Dependency.of("info.picocli", "picocli", "4.7.3")) .fetch() @@ -282,22 +284,22 @@ object Tests { execute( s"%AddJar $jarUri" + ls + "import picocli.CommandLine" + ls, - "import $cp.$" + ls + ls + - "import picocli.CommandLine" + ls, + "import $cp.$" + ls + maybePostImportNewLine(isScala2) + + "import picocli.CommandLine" + maybePostImportNewLine(isScala2), ignoreStreams = true, trimReplyLines = true ) else { execute( s"%AddJar $jarUri", - "import $cp.$" + maybePostImportNewLine(scalaVersion.startsWith("2.")), + "import $cp.$" + maybePostImportNewLine(isScala2), ignoreStreams = true, trimReplyLines = true ) execute( "import picocli.CommandLine", - "import picocli.CommandLine" + maybePostImportNewLine(scalaVersion.startsWith("2.")) + "import picocli.CommandLine" + maybePostImportNewLine(isScala2) ) } } @@ -308,6 +310,8 @@ object Tests { ): Unit = runner.withSession("--toree-magics") { implicit session => + val isScala2 = scalaVersion.startsWith("2.") + val jar = coursierapi.Fetch.create() .addDependencies(coursierapi.Dependency.of("info.picocli", "picocli", "4.7.3")) .fetchResult() @@ -329,22 +333,22 @@ object Tests { execute( s"%AddJar $jar" + ls + "import picocli.CommandLine" + ls, - "import $cp.$" + ls + ls + - "import picocli.CommandLine" + ls, + "import $cp.$" + maybePostImportNewLine(isScala2) + ls + + "import picocli.CommandLine" + maybePostImportNewLine(isScala2), ignoreStreams = true, trimReplyLines = true ) else { execute( s"%AddJar $jar", - "import $cp.$" + maybePostImportNewLine(scalaVersion.startsWith("2.")), + "import $cp.$" + maybePostImportNewLine(isScala2), ignoreStreams = true, trimReplyLines = true ) execute( "import picocli.CommandLine", - "import picocli.CommandLine" + maybePostImportNewLine(scalaVersion.startsWith("2.")) + "import picocli.CommandLine" + maybePostImportNewLine(isScala2) ) } } @@ -461,6 +465,9 @@ object Tests { runner.withExtraClassPathSession(extraCp)("--toree-magics", "--predef", predefPath.toString) { implicit session => + + val isScala2 = scalaVersion.startsWith("2.") + execute( "import picocli.CommandLine", errors = Seq( @@ -471,13 +478,13 @@ object Tests { execute( "%AddJar foo://thing/a/b" + ls, - "import $cp.$" + ls, + "import $cp.$" + maybePostImportNewLine(isScala2), trimReplyLines = true ) execute( "import picocli.CommandLine", - "import picocli.CommandLine" + maybePostImportNewLine(scalaVersion.startsWith("2.")) + "import picocli.CommandLine" + maybePostImportNewLine(isScala2) ) } } @@ -613,7 +620,8 @@ object Tests { def extraCp(scalaVersion: String)(implicit sessionId: SessionId, runner: Runner): Unit = { - val sbv = scalaVersion.split('.').take(2).mkString(".") + val sbv = scalaVersion.split('.').take(2).mkString(".") + val isScala2 = scalaVersion.startsWith("2.") val kernelShapelessVersion = "2.3.10" // might need to be updated when bumping case-app val testShapelessVersion = "2.3.3" // no need to bump that one @@ -635,7 +643,7 @@ object Tests { execute( "import shapeless._" + ls + """val l = 1 :: "aa" :: true :: HNil""", - "import shapeless._" + ls + ls + + "import shapeless._" + maybePostImportNewLine(isScala2) + ls + """l: Int :: String :: Boolean :: HNil = 1 :: "aa" :: true :: HNil""" ) @@ -742,11 +750,13 @@ object Tests { } } - def addDependency()(implicit + def addDependency(scalaVersion: String)(implicit sessionId: SessionId, runner: Runner ): Unit = runner.withSession() { implicit session => + val isScala2 = scalaVersion.startsWith("2.") + execute( """//> using dep "org.typelevel::cats-kernel:2.6.1" |import cats.kernel._ @@ -754,25 +764,26 @@ object Tests { | Monoid.instance[String]("", (a, b) => a + b) | .combineAll(List("Hello", "", "")) |""".stripMargin, - """import cats.kernel._ - | - |msg: String = "Hello"""".stripMargin + s"""import cats.kernel._${maybePostImportNewLine(isScala2)} + |msg: String = "Hello"""".stripMargin ) } - def addRepository()(implicit + def addRepository(scalaVersion: String)(implicit sessionId: SessionId, runner: Runner ): Unit = runner.withSession() { implicit session => + + val isScala2 = scalaVersion.startsWith("2.") + // that repository should already have been added by Almond, so we don't test much hereā€¦ execute( """//> using repository "jitpack" |//> using dep "com.github.jupyter:jvm-repr:0.4.0" |import jupyter._ |""".stripMargin, - """import jupyter._ - |""".stripMargin + "import jupyter._" + maybePostImportNewLine(isScala2) ) } @@ -793,18 +804,19 @@ object Tests { val errorMessage = if (scalaVersion.startsWith("2.13.")) - """cell2.sc:3: method getValue in class Helper is deprecated (since 0.1): foo + """cell2.sc:4: method getValue in class Helper is deprecated (since 0.1): foo |val n = getValue() | ^ |No warnings can be incurred under -Werror. |Compilation Failed""".stripMargin else if (scalaVersion.startsWith("2.12.")) - """cell2.sc:3: method getValue in class Helper is deprecated (since 0.1): foo + """cell2.sc:4: method getValue in class Helper is deprecated (since 0.1): foo |val n = getValue() | ^ |No warnings can be incurred under -Xfatal-warnings. |Compilation Failed""".stripMargin else + // FIXME The line number is wrong here """-- Error: cell2.sc:3:8 --------------------------------------------------------- |3 |val n = getValue() | | ^^^^^^^^ diff --git a/project/deps.sc b/project/deps.sc index a6bad1aad..53e0af3ad 100644 --- a/project/deps.sc +++ b/project/deps.sc @@ -2,7 +2,7 @@ import mill._ import mill.scalalib._ object Versions { - def ammonite = "3.0.0-M0-45-9c598c7c" + def ammonite = "3.0.0-M0-50-f03f2d82" def caseApp = "2.1.0-M25" def coursier = "2.1.5" def jsoniterScala = "2.13.5"