Skip to content

Commit

Permalink
Merge branch 'main' into update/ammonite-compiler-3.0.0-M2-1-3763a1d4
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed May 17, 2024
2 parents 3863154 + 1c1301c commit fe6ffc4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class KernelTestsTwoStepStartup213 extends KernelTestsDefinitions {
|""".stripMargin,
expectError = true,
stderr =
"""cell2.sc:6: method foo in class Helper is deprecated
"""cmd2.sc:6: method foo in class Helper is deprecated
|val res2_1 = foo()
| ^
|No warnings can be incurred under -Werror.
Expand Down Expand Up @@ -63,7 +63,7 @@ class KernelTestsTwoStepStartup213 extends KernelTestsDefinitions {
|""".stripMargin,
expectError = true,
stderr =
"""cell2.sc:4: method foo in class Helper is deprecated
"""cmd2.sc:4: method foo in class Helper is deprecated
|val res2_1 = foo()
| ^
|No warnings can be incurred under -Werror.
Expand Down Expand Up @@ -92,7 +92,7 @@ class KernelTestsTwoStepStartup213 extends KernelTestsDefinitions {
|""".stripMargin,
expectError = true,
stderr =
"""cell1.sc:7: method foo in class Helper is deprecated
"""cmd1.sc:7: method foo in class Helper is deprecated
|val res1_1 = foo()
| ^
|No warnings can be incurred under -Werror.
Expand Down Expand Up @@ -127,7 +127,7 @@ class KernelTestsTwoStepStartup213 extends KernelTestsDefinitions {
|""".stripMargin,
expectError = true,
stderr =
"""cell2.sc:6: method foo in class Helper is deprecated
"""cmd2.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 @@ -162,7 +162,7 @@ class KernelTestsTwoStepStartup213 extends KernelTestsDefinitions {
|""".stripMargin,
expectError = true,
stderr =
"""cell2.sc:6: method foo in class Helper is deprecated
"""cmd2.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 @@ -57,6 +57,14 @@ object AmmInterpreter {
ImportData("almond.toree.ToreeCompatibility.KernelToreeOps")
)

/* Spark 3.5.1 expects `cmd` in `org.apache.spark.sql.catalyst.encoders.OuterScopes`.
* This name is confusing to users and `cell` is more obvious. However, that change depends
* on customizing the `CodeClassWrapper` so
* `org.apache.spark.sql.catalyst.encoders.OuterScopes.addOuterScope(this)`
* calls are automatically added. Or, less preferably, changing the regex in Spark.
*/
private def ammoniteWrapperNamePrefix = "cmd"

/** Instantiate an [[ammonite.interp.Interpreter]] to be used from [[ScalaInterpreter]].
*/
def apply(
Expand Down Expand Up @@ -139,7 +147,7 @@ object AmmInterpreter {
verboseOutput = true, // ???
alreadyLoadedDependencies =
ammonite.main.Defaults.alreadyLoadedDependencies("almond/almond-user-dependencies.txt"),
wrapperNamePrefix = "cell"
wrapperNamePrefix = ammoniteWrapperNamePrefix
)
val outputDir0 = outputDir match {
case Left(path) => Some(path.toNIO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ object ScalafmtTests extends TestSuite {
val expectedCode = formattedSnippet1

val request = Format.Request(ListMap(
"cell1" -> initialCode
"cmd1" -> initialCode
))
val messages0 = messages(scalafmt, request)
val processMessages = endsWithFormatReply(messages0)
Expand All @@ -134,8 +134,8 @@ object ScalafmtTests extends TestSuite {
println(formattedCodeMap)

val resp = formattedCodeMap.getOrElse(
"cell1",
sys.error("No data for key 'cell1' in response")
"cmd1",
sys.error("No data for key 'cmd1' in response")
)
assert(resp.initial_code == initialCode)
val formattedCode = resp.code.getOrElse {
Expand All @@ -146,8 +146,8 @@ object ScalafmtTests extends TestSuite {

test("multiple cells") {
val request = Format.Request(ListMap(
"cell1" -> snippet1,
"cell2" -> snippet2
"cmd1" -> snippet1,
"cmd2" -> snippet2
))
val messages0 = messages(scalafmt, request)
val processMessages = endsWithFormatReply(messages0)
Expand All @@ -156,8 +156,8 @@ object ScalafmtTests extends TestSuite {
println(formattedCodeMap)

val resp1 = formattedCodeMap.getOrElse(
"cell1",
sys.error("No data for key 'cell1' in response")
"cmd1",
sys.error("No data for key 'cmd1' in response")
)
assert(resp1.initial_code == snippet1)
val formattedCode1 = resp1.code.getOrElse {
Expand All @@ -166,8 +166,8 @@ object ScalafmtTests extends TestSuite {
assert(formattedCode1 == formattedSnippet1)

val resp2 = formattedCodeMap.getOrElse(
"cell2",
sys.error("No data for key 'cell2' in response")
"cmd2",
sys.error("No data for key 'cmd2' in response")
)
assert(resp2.initial_code == snippet2)
val formattedCode2 = resp2.code.getOrElse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,30 +737,30 @@ object Tests {

val errorOutput =
if (scalaVersion.startsWith("2."))
"""cell1.sc:2: not found: value foo
"""cmd1.sc:2: not found: value foo
| foo
| ^
|cell1.sc:3: not found: value bar
|cmd1.sc:3: not found: value bar
| bar
| ^
|cell1.sc:4: not found: value other
|cmd1.sc:4: not found: value other
| other
| ^
|Compilation Failed""".stripMargin
else
"""-- [E006] Not Found Error: cell1.sc:2:2 ----------------------------------------
"""-- [E006] Not Found Error: cmd1.sc:2:2 -----------------------------------------
|2 | foo
| | ^^^
| | Not found: foo
| |
| | longer explanation available when compiling with `-explain`
|-- [E006] Not Found Error: cell1.sc:3:2 ----------------------------------------
|-- [E006] Not Found Error: cmd1.sc:3:2 -----------------------------------------
|3 | bar
| | ^^^
| | Not found: bar
| |
| | longer explanation available when compiling with `-explain`
|-- [E006] Not Found Error: cell1.sc:4:2 ----------------------------------------
|-- [E006] Not Found Error: cmd1.sc:4:2 -----------------------------------------
|4 | other
| | ^^^^^
| | Not found: other
Expand Down Expand Up @@ -839,20 +839,20 @@ object Tests {

val errorMessage =
if (scalaVersion.startsWith("2.13."))
"""cell2.sc:4: method getValue in class Helper is deprecated (since 0.1): foo
"""cmd2.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:4: method getValue in class Helper is deprecated (since 0.1): foo
"""cmd2.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 ---------------------------------------------------------
"""-- Error: cmd2.sc:3:8 ----------------------------------------------------------
|3 |val n = getValue()
| | ^^^^^^^^
| | method getValue in class Helper is deprecated since 0.1: foo
Expand Down
2 changes: 1 addition & 1 deletion project/deps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object Deps {
def directiveHandler = ivy"io.github.alexarchambault.scala-cli::directive-handler:0.1.4"
def expecty = ivy"com.eed3si9n.expecty::expecty:0.16.0"
def fansi = ivy"com.lihaoyi::fansi:0.5.0"
def fs2 = ivy"co.fs2::fs2-core:3.9.4"
def fs2 = ivy"co.fs2::fs2-core:3.10.2"
def jansi = ivy"org.fusesource.jansi:jansi:2.4.1"
def jeromq = ivy"org.zeromq:jeromq:0.5.4"
def jsoniterScalaCore =
Expand Down

0 comments on commit fe6ffc4

Please sign in to comment.