mirror of
https://github.com/apple/pkl.git
synced 2026-03-27 11:31:11 +01:00
Fix handling of file: module URIs with non-ASCII characters (#696)
Addresses an issue where Pkl cannot evaluate files with non-ASCII characters.
This commit is contained in:
@@ -1457,6 +1457,62 @@ result = someLib.x
|
||||
assertThat(output).isEqualTo("result = 1\n")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `eval file with non-ASCII name`() {
|
||||
val tempDirUri = tempDir.toUri()
|
||||
val dir = tempDir.resolve("🤬").createDirectory()
|
||||
val file =
|
||||
writePklFile(
|
||||
dir.resolve("日本語.pkl").toString(),
|
||||
"""
|
||||
日本語 = "Japanese language"
|
||||
readDir = read(".").text
|
||||
readDirFile = read("$tempDirUri🤬").text
|
||||
readOne = read("日本語.pkl").text.split("\n").first
|
||||
readOneFile = read("$tempDirUri🤬/日本語.pkl").text.split("\n").first
|
||||
readGlob = read*("./日*.pkl").keys
|
||||
readGlobFile = read*("$tempDirUri**/*.pkl").keys.map((it) -> it.replaceAll("$tempDirUri".replaceAll("///", "/"), ""))
|
||||
importOne = import("日本語.pkl").readOne
|
||||
importOneFile = import("$tempDirUri🤬/日本語.pkl").日本語
|
||||
importGlob = import*("./日*.pkl").keys
|
||||
importGlobFile = import*("$tempDirUri**/*.pkl").keys.map((it) -> it.replaceAll("$tempDirUri".replaceAll("///", "/"), ""))
|
||||
"""
|
||||
.trimIndent()
|
||||
)
|
||||
val output =
|
||||
evalToConsole(
|
||||
CliEvaluatorOptions(
|
||||
CliBaseOptions(sourceModules = listOf(file)),
|
||||
)
|
||||
)
|
||||
|
||||
val tripleQuote = "\"\"\""
|
||||
assertThat(output)
|
||||
.isEqualTo(
|
||||
"""
|
||||
日本語 = "Japanese language"
|
||||
readDir = $tripleQuote
|
||||
日本語.pkl
|
||||
|
||||
$tripleQuote
|
||||
readDirFile = $tripleQuote
|
||||
日本語.pkl
|
||||
|
||||
$tripleQuote
|
||||
readOne = "日本語 = \"Japanese language\""
|
||||
readOneFile = "日本語 = \"Japanese language\""
|
||||
readGlob = Set("./日本語.pkl")
|
||||
readGlobFile = Set("🤬/日本語.pkl")
|
||||
importOne = "日本語 = \"Japanese language\""
|
||||
importOneFile = "Japanese language"
|
||||
importGlob = Set("./日本語.pkl")
|
||||
importGlobFile = Set("🤬/日本語.pkl")
|
||||
|
||||
"""
|
||||
.trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
private fun evalModuleThatImportsPackage(certsFile: Path?, testPort: Int = -1) {
|
||||
val moduleUri =
|
||||
writePklFile(
|
||||
|
||||
Reference in New Issue
Block a user