mirror of
https://github.com/apple/pkl.git
synced 2026-03-31 06:03:11 +02:00
Do not crash, but suggest '--multiple-file-output-path' when specifying a directory as output file (#1038)
When specifying a directory instead of a file for the output, pkl won't crash anymore, but instead output an error message, suggesting --multiple-file-output-path.
This commit is contained in:
@@ -725,6 +725,39 @@ result = someLib.x
|
||||
assertThat(output).endsWith("\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `file output throws if output file is a directory`() {
|
||||
val sourceFiles =
|
||||
listOf(
|
||||
writePklFile(
|
||||
"test.pkl",
|
||||
"""
|
||||
name = "test"
|
||||
output {
|
||||
files {
|
||||
["\(name).txt"] {
|
||||
text = "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
.trimIndent(),
|
||||
)
|
||||
)
|
||||
val err =
|
||||
assertThrows<CliException> {
|
||||
evalToFiles(
|
||||
CliEvaluatorOptions(
|
||||
CliBaseOptions(sourceModules = sourceFiles),
|
||||
outputPath = tempDir.toString(),
|
||||
)
|
||||
)
|
||||
}
|
||||
assertThat(err)
|
||||
.hasMessageContaining("Output file `$tempDir` is a directory. ")
|
||||
.hasMessageContaining("Did you mean `--multiple-file-output-path`?")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `multiple file output writes multiple files to the provided directory`() {
|
||||
val contents =
|
||||
|
||||
Reference in New Issue
Block a user