Skip to content

Commit

Permalink
Update Ammonite (fork) to 3.0.0-M0-50-f03f2d82 (#1206)
Browse files Browse the repository at this point in the history
Line number updates in test fixtures are legit. This needed fixing.
  • Loading branch information
alexarchambault authored Jul 16, 2023
1 parent 990da6a commit 9bcc08f
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 42 deletions.
3 changes: 1 addition & 2 deletions examples/plotly-scala.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 5 additions & 11 deletions examples/scalapy-displays.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
)
}
}
Expand All @@ -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()
Expand All @@ -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)
)
}
}
Expand Down Expand Up @@ -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(
Expand All @@ -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)
)
}
}
Expand Down Expand Up @@ -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
Expand All @@ -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"""
)

Expand Down Expand Up @@ -742,37 +750,40 @@ 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._
|val msg =
| 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)
)
}

Expand All @@ -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()
| | ^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion project/deps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9bcc08f

Please sign in to comment.