Skip to content

Commit

Permalink
Fix printing of compilation errors in 2.12
Browse files Browse the repository at this point in the history
Which was missing some new lines
  • Loading branch information
alexarchambault committed Jun 29, 2023
1 parent 18b5a40 commit 522c479
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,11 @@ abstract class KernelTestsDefinitions extends AlmondFunSuite {
}
}

test("compilation error") {
kernelLauncher.withKernel { implicit runner =>
implicit val sessionId: SessionId = SessionId()
almond.integration.Tests.compilationError(kernelLauncher.defaultScalaVersion)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ final class Execute(
capture0.out,
capture0.err,
resultStream,
s => currentPublishOpt0.fold(Console.err.println(s))(_.stderr(s)),
s => currentPublishOpt0.fold(Console.err.println(s))(_.stderr(s)),
s => currentPublishOpt0.fold(Console.err.println(s))(_.stderr(s + System.lineSeparator())),
s => currentPublishOpt0.fold(Console.err.println(s))(_.stderr(s + System.lineSeparator())),
// to stdout in notebooks, not to get a red background,
// but stderr in the console, not to pollute stdout
s => currentPublishOpt0.fold(Console.err.println(s))(_.stdout(s))
s => currentPublishOpt0.fold(Console.err.println(s))(_.stdout(s + System.lineSeparator()))
)

def history: History =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,4 +687,59 @@ object Tests {
}
}

def compilationError(scalaVersion: String)(implicit
sessionId: SessionId,
runner: Runner
): Unit = {

val errorOutput =
if (scalaVersion.startsWith("2."))
"""cell1.sc:2: not found: value foo
| foo
| ^
|cell1.sc:3: not found: value bar
| bar
| ^
|cell1.sc:4: not found: value other
| other
| ^
|Compilation Failed""".stripMargin
else
"""-- [E006] Not Found Error: cell1.sc:2:2 ----------------------------------------
|2 | foo
| | ^^^
| | Not found: foo
| |
| | longer explanation available when compiling with `-explain`
|-- [E006] Not Found Error: cell1.sc:3:2 ----------------------------------------
|3 | bar
| | ^^^
| | Not found: bar
| |
| | longer explanation available when compiling with `-explain`
|-- [E006] Not Found Error: cell1.sc:4:2 ----------------------------------------
|4 | other
| | ^^^^^
| | Not found: other
| |
| | longer explanation available when compiling with `-explain`
|Compilation Failed""".stripMargin

runner.withSession() { implicit session =>
execute(
"""val n = {
| foo
| bar
| other
|}
|""".stripMargin,
expectError = true,
stderr = errorOutput,
errors = Seq(
("", "Compilation Failed", List("Compilation Failed"))
)
)
}
}

}

0 comments on commit 522c479

Please sign in to comment.