mirror of
https://github.com/apple/pkl.git
synced 2026-04-18 14:39:54 +02:00
Encode filepaths to be safe on Windows
This changes the file paths to use characters that are safe for Windows. Channges the output of the following: * Package cache directory * Generated pkl-doc files * Kotlin generated code Unsafe characters are encoded as (<hex>). For example, the colon character `:` is encoded as `(3a)`. Additionally, this changes the cache directory prefix (package-1 to package-2). Follows the design of https://github.com/apple/pkl-evolution/pull/3
This commit is contained in:
@@ -1501,6 +1501,24 @@ class KotlinCodeGeneratorTest {
|
||||
confirmSerDe(bigStruct)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `encoded file paths`(@TempDir path: Path) {
|
||||
val kotlinCode =
|
||||
generateKotlinFiles(
|
||||
path,
|
||||
PklModule(
|
||||
"FooBar.pkl",
|
||||
"""
|
||||
module `Foo*Bar`
|
||||
|
||||
someProp: String
|
||||
"""
|
||||
.trimIndent()
|
||||
)
|
||||
)
|
||||
assertThat(kotlinCode).containsKey("kotlin/Foo(2a)Bar.kt")
|
||||
}
|
||||
|
||||
private fun generateFiles(tempDir: Path, vararg pklModules: PklModule): Map<String, String> {
|
||||
val pklFiles = pklModules.map { it.writeToDisk(tempDir.resolve("pkl/${it.name}.pkl")) }
|
||||
val evaluator = Evaluator.preconfigured()
|
||||
|
||||
Reference in New Issue
Block a user