mirror of
https://github.com/apple/pkl.git
synced 2026-03-23 17:41:10 +01:00
Fix display of evaluation errors thrown by command convert/transformAll (#1431)
This commit is contained in:
@@ -942,7 +942,52 @@ class CliCommandRunnerTest {
|
||||
assertThrows<CliktError> {
|
||||
runToStdout(CliBaseOptions(sourceModules = listOf(moduleUri)), listOf("hi"))
|
||||
}
|
||||
assertThat(exc.message).isEqualTo("oops!")
|
||||
assertThat(exc.message).contains("oops!")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `convert with eval error`() {
|
||||
val moduleUri =
|
||||
writePklFile(
|
||||
"cmd.pkl",
|
||||
renderOptions +
|
||||
"""
|
||||
class Options {
|
||||
@Argument { convert = (it) -> it.noSuchMethod() }
|
||||
foo: String
|
||||
}
|
||||
"""
|
||||
.trimIndent(),
|
||||
)
|
||||
|
||||
val exc =
|
||||
assertThrows<CliktError> {
|
||||
runToStdout(CliBaseOptions(sourceModules = listOf(moduleUri)), listOf("hi"))
|
||||
}
|
||||
assertThat(exc.message).contains("Cannot find method `noSuchMethod` in class `String`.")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `convert with stack overflow`() {
|
||||
val moduleUri =
|
||||
writePklFile(
|
||||
"cmd.pkl",
|
||||
renderOptions +
|
||||
"""
|
||||
const function overflow(it) = overflow(it)
|
||||
class Options {
|
||||
@Argument { convert = (it) -> overflow(it) }
|
||||
foo: String
|
||||
}
|
||||
"""
|
||||
.trimIndent(),
|
||||
)
|
||||
|
||||
val exc =
|
||||
assertThrows<CliktError> {
|
||||
runToStdout(CliBaseOptions(sourceModules = listOf(moduleUri)), listOf("hi"))
|
||||
}
|
||||
assertThat(exc.message).contains("A stack overflow occurred.")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user