mirror of
https://github.com/apple/pkl.git
synced 2026-04-01 06:33:26 +02:00
Add support for Windows (#492)
This adds support for Windows. The in-language path separator is still `/`, to ensure Pkl programs are cross-platform. Log lines are written using CRLF endings on Windows. Modules that are combined with `--module-output-separator` uses LF endings to ensure consistent rendering across platforms. `jpkl` does not work on Windows as a direct executable. However, it can work with `java -jar jpkl`. Additional details: * Adjust git settings for Windows * Add native executable for pkl cli * Add jdk17 windows Gradle check in CI * Adjust CI test reports to be staged within Gradle rather than by shell script. * Fix: encode more characters that are not safe Windows paths * Skip running tests involving symbolic links on Windows (these require administrator privileges to run). * Introduce custom implementation of `IoUtils.relativize` * Allow Gradle to initialize ExecutableJar `Property` values * Add Gradle flag to enable remote JVM debugging Co-authored-by: Philip K.F. Hölzenspies <holzensp@gmail.com>
This commit is contained in:
@@ -37,6 +37,7 @@ import org.pkl.commons.test.PackageServer
|
||||
import org.pkl.commons.test.listFilesRecursively
|
||||
import org.pkl.commons.toPath
|
||||
import org.pkl.core.Version
|
||||
import org.pkl.core.util.IoUtils
|
||||
import org.pkl.doc.DocGenerator.Companion.current
|
||||
|
||||
class CliDocGeneratorTest {
|
||||
@@ -92,11 +93,17 @@ class CliDocGeneratorTest {
|
||||
private val actualOutputFiles: List<Path> by lazy { actualOutputDir.listFilesRecursively() }
|
||||
|
||||
private val expectedRelativeOutputFiles: List<String> by lazy {
|
||||
expectedOutputFiles.map { expectedOutputDir.relativize(it).toString() }
|
||||
expectedOutputFiles.map { path ->
|
||||
IoUtils.toNormalizedPathString(expectedOutputDir.relativize(path)).let { str ->
|
||||
// Git will by default clone symlinks as shortcuts on Windows, and shortcuts have a
|
||||
// `.lnk` extension.
|
||||
if (IoUtils.isWindows() && str.endsWith(".lnk")) str.dropLast(4) else str
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val actualRelativeOutputFiles: List<String> by lazy {
|
||||
actualOutputFiles.map { actualOutputDir.relativize(it).toString() }
|
||||
actualOutputFiles.map { IoUtils.toNormalizedPathString(actualOutputDir.relativize(it)) }
|
||||
}
|
||||
|
||||
private val binaryFileExtensions =
|
||||
@@ -219,6 +226,11 @@ class CliDocGeneratorTest {
|
||||
.withFailMessage("Test bug: $actualFile should exist but does not.")
|
||||
.exists()
|
||||
|
||||
// symlinks on Git and Windows is rather finnicky; they create shortcuts by default unless
|
||||
// a core Git option is set. Also, by default, symlinks require administrator privileges to run.
|
||||
// We'll just test that the symlink got created but skip verifying that it points to the right
|
||||
// place.
|
||||
if (actualFile.isSymbolicLink() && IoUtils.isWindows()) return
|
||||
val expectedFile = expectedOutputDir.resolve(relativeFilePath)
|
||||
if (expectedFile.exists()) {
|
||||
when {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.pkl.doc
|
||||
|
||||
import java.net.URI
|
||||
import java.nio.file.Path
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.AfterAll
|
||||
import org.junit.jupiter.api.Test
|
||||
@@ -221,6 +222,6 @@ class DocScopeTest {
|
||||
val scope = SiteScope(listOf(), mapOf(), { evaluator.evaluateSchema(uri(it)) }, outputDir)
|
||||
|
||||
// used to return `/non/index.html`
|
||||
assertThat(scope.url.path).isEqualTo("/non/existing/index.html")
|
||||
assertThat(scope.url.toPath()).isEqualTo(Path.of("/non/existing/index.html").toAbsolutePath())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user