Update Kotlin to 2.0 (#900)

- update Kotlin from 1.7.10 to 2.0.21
  - Kotlin 1.6 dependencies in Gradle lock files are expected because kotlinc,
    which is also used by some tests, internally uses some 1.6 dependencies
    for backwards compatibility reasons.
- update kotlinx-html and kotlinx-serialization
- adapt Kotlin code where necessary
- use Kotlin stdlib Path APIs where possible
- fix IntelliJ Kotlin inspection warnings
- reformat code with `./gradlew spotlessApply`
  - ktfmt adds lots of trailing commas
- Add workaround to fix IntelliJ "unresolved reference" errors
This commit is contained in:
odenix
2025-01-23 14:41:59 -08:00
committed by GitHub
parent cdd6d52642
commit 258eda8630
87 changed files with 1042 additions and 1004 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,10 +17,10 @@ package org.pkl.core
import java.net.URI
import java.nio.file.Path
import kotlin.io.path.createParentDirectories
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.test.PackageServer
import org.pkl.commons.writeString
import org.pkl.core.http.HttpClient
@@ -36,7 +36,7 @@ class AnalyzerTest {
listOf(ModuleKeyFactories.file, ModuleKeyFactories.standardLibrary, ModuleKeyFactories.pkg),
null,
null,
HttpClient.dummyClient()
HttpClient.dummyClient(),
)
@Test
@@ -62,8 +62,8 @@ class AnalyzerTest {
setOf(
ImportGraph.Import(URI("pkl:base")),
ImportGraph.Import(URI("pkl:json")),
ImportGraph.Import(URI("pkl:xml"))
)
ImportGraph.Import(URI("pkl:xml")),
),
)
}
@@ -88,8 +88,8 @@ class AnalyzerTest {
file1 to
setOf(ImportGraph.Import(file1), ImportGraph.Import(file2), ImportGraph.Import(file3)),
file2 to emptySet(),
file3 to emptySet()
),
file3 to emptySet(),
)
)
}
@@ -129,7 +129,7 @@ class AnalyzerTest {
file1 to setOf(ImportGraph.Import(URI("package://localhost:0/birds@0.5.0#/Bird.pkl"))),
URI("package://localhost:0/birds@0.5.0#/Bird.pkl") to
setOf(ImportGraph.Import(URI("package://localhost:0/fruit@1.0.5#/Fruit.pkl"))),
URI("package://localhost:0/fruit@1.0.5#/Fruit.pkl") to emptySet()
URI("package://localhost:0/fruit@1.0.5#/Fruit.pkl") to emptySet(),
)
)
}
@@ -185,11 +185,11 @@ class AnalyzerTest {
ModuleKeyFactories.file,
ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.pkg,
ModuleKeyFactories.projectpackage
ModuleKeyFactories.projectpackage,
),
tempDir.resolve("packages"),
project.dependencies,
HttpClient.dummyClient()
HttpClient.dummyClient(),
)
val file1 =
tempDir
@@ -209,7 +209,7 @@ class AnalyzerTest {
setOf(ImportGraph.Import(URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl"))),
URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl") to
setOf(ImportGraph.Import(URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl"))),
URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl") to emptySet()
URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl") to emptySet(),
)
)
assertThat(result.resolvedImports)
@@ -219,7 +219,7 @@ class AnalyzerTest {
URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl") to
URI("projectpackage://localhost:0/birds@0.5.0#/Bird.pkl"),
URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl") to
URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl")
URI("projectpackage://localhost:0/fruit@1.0.5#/Fruit.pkl"),
)
)
}
@@ -297,23 +297,23 @@ class AnalyzerTest {
ModuleKeyFactories.file,
ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.pkg,
ModuleKeyFactories.projectpackage
ModuleKeyFactories.projectpackage,
),
tempDir.resolve("packages"),
project.dependencies,
HttpClient.dummyClient()
HttpClient.dummyClient(),
)
val result = analyzer.importGraph(mainPkl.toUri())
val birdUri = URI("projectpackage://localhost:0/birds@1.0.0#/bird.pkl")
assertThat(result.imports)
.isEqualTo(
mapOf(mainPkl.toUri() to setOf(ImportGraph.Import(birdUri)), birdUri to emptySet()),
mapOf(mainPkl.toUri() to setOf(ImportGraph.Import(birdUri)), birdUri to emptySet())
)
assertThat(result.resolvedImports)
.isEqualTo(
mapOf(
mainPkl.toUri() to mainPkl.toRealPath().toUri(),
birdUri to birdModule.toRealPath().toUri()
birdUri to birdModule.toRealPath().toUri(),
)
)
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -120,6 +120,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofNanos(999999999999))
assertThat(Duration(999999999999999.0, NANOS).toJavaDuration())
.isEqualTo(java.time.Duration.ofNanos(999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(9999999999999999.0, NANOS).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofNanos(9999999999999999))
@@ -133,6 +134,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofSeconds(999999999999))
assertThat(Duration(999999999999999.0, SECONDS).toJavaDuration())
.isEqualTo(java.time.Duration.ofSeconds(999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(9999999999999999.0, SECONDS).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofSeconds(9999999999999999))
@@ -146,6 +148,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofMinutes(999999999999))
assertThat(Duration(999999999999999.0, MINUTES).toJavaDuration())
.isEqualTo(java.time.Duration.ofMinutes(999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(9999999999999999.0, MINUTES).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofMinutes(9999999999999999))
@@ -158,7 +161,10 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofHours(999999999999))
assertThat(Duration(999999999999999.0, HOURS).toJavaDuration())
.isEqualTo(java.time.Duration.ofHours(999999999999999))
assertThrows<ArithmeticException> { Duration(9999999999999999.0, HOURS).toJavaDuration() }
assertThrows<ArithmeticException> {
@Suppress("FloatingPointLiteralPrecision")
Duration(9999999999999999.0, HOURS).toJavaDuration()
}
assertThat(Duration(999.0, DAYS).toJavaDuration()).isEqualTo(java.time.Duration.ofDays(999))
assertThat(Duration(999999.0, DAYS).toJavaDuration())
@@ -181,6 +187,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofNanos(-999999999999))
assertThat(Duration(-999999999999999.0, NANOS).toJavaDuration())
.isEqualTo(java.time.Duration.ofNanos(-999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(-9999999999999999.0, NANOS).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofNanos(-9999999999999999))
@@ -194,6 +201,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofSeconds(-999999999999))
assertThat(Duration(-999999999999999.0, SECONDS).toJavaDuration())
.isEqualTo(java.time.Duration.ofSeconds(-999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(-9999999999999999.0, SECONDS).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofSeconds(-9999999999999999))
@@ -207,6 +215,7 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofMinutes(-999999999999))
assertThat(Duration(-999999999999999.0, MINUTES).toJavaDuration())
.isEqualTo(java.time.Duration.ofMinutes(-999999999999999))
@Suppress("FloatingPointLiteralPrecision")
assertThat(Duration(-9999999999999999.0, MINUTES).toJavaDuration())
.isNotEqualTo(java.time.Duration.ofMinutes(-9999999999999999))
@@ -219,7 +228,10 @@ class DurationTest {
.isEqualTo(java.time.Duration.ofHours(-999999999999))
assertThat(Duration(-999999999999999.0, HOURS).toJavaDuration())
.isEqualTo(java.time.Duration.ofHours(-999999999999999))
assertThrows<ArithmeticException> { Duration(-9999999999999999.0, HOURS).toJavaDuration() }
assertThrows<ArithmeticException> {
@Suppress("FloatingPointLiteralPrecision")
Duration(-9999999999999999.0, HOURS).toJavaDuration()
}
assertThat(Duration(-999.0, DAYS).toJavaDuration()).isEqualTo(java.time.Duration.ofDays(-999))
assertThat(Duration(-999999.0, DAYS).toJavaDuration())

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ import org.junit.jupiter.api.assertThrows
class EvaluateExpressionTest {
companion object {
val evaluator by lazy { Evaluator.preconfigured() }
private val evaluator by lazy { Evaluator.preconfigured() }
@AfterAll
@JvmStatic
@@ -64,7 +64,7 @@ class EvaluateExpressionTest {
}
"""
.trimIndent(),
"foo.bar"
"foo.bar",
)
assertThat(resp).isEqualTo(2L)
@@ -84,7 +84,7 @@ class EvaluateExpressionTest {
}
"""
.trimIndent(),
"output.text"
"output.text",
)
assertThat(result)

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import java.nio.file.Files
import java.nio.file.Path
import java.util.*
import java.util.regex.Pattern
import kotlin.io.path.createParentDirectories
import kotlin.io.path.writeText
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatCode
@@ -30,7 +31,6 @@ import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.createTempFile
import org.pkl.commons.test.PackageServer
import org.pkl.commons.toPath
@@ -47,7 +47,7 @@ class EvaluatorTest {
companion object {
private val evaluator = Evaluator.preconfigured()
private const val sourceText = "name = \"pigeon\"; age = 10 + 20"
@Suppress("ConstPropertyName") private const val sourceText = "name = \"pigeon\"; age = 10 + 20"
private object CustomModuleKeyFactory : ModuleKeyFactory {
override fun create(uri: URI): Optional<ModuleKey> {
@@ -275,7 +275,7 @@ class EvaluatorTest {
SecurityManagers.defaultAllowedModules,
SecurityManagers.defaultAllowedResources,
SecurityManagers.defaultTrustLevels,
tempDir
tempDir,
)
)
.build()
@@ -315,7 +315,7 @@ class EvaluatorTest {
}
"""
.trimIndent()
val output = evaluator.evaluateOutputFiles(ModuleSource.text(program))
val output = evaluator.evaluateOutputFiles(text(program))
assertThat(output.keys).isEqualTo(setOf("foo.yml", "bar.yml", "bar/biz.yml", "bar/../bark.yml"))
assertThat(output["foo.yml"]?.text).isEqualTo("foo: foo text")
assertThat(output["bar.yml"]?.text).isEqualTo("bar: bar text")
@@ -361,7 +361,7 @@ class EvaluatorTest {
ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.pkg,
ModuleKeyFactories.projectpackage,
ModuleKeyFactories.file
ModuleKeyFactories.file,
)
)
}
@@ -430,7 +430,7 @@ class EvaluatorTest {
ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.pkg,
ModuleKeyFactories.projectpackage,
ModuleKeyFactories.file
ModuleKeyFactories.file,
)
)
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -94,17 +94,17 @@ abstract class AbstractLanguageSnippetTestsEngine : InputOutputTestEngine() {
protected fun String.stripFilePaths(): String =
replace(IoUtils.toNormalizedPathString(snippetsDir), replacement)
protected fun String.stripLineNumbers() =
protected fun String.stripLineNumbers(): String =
replace(lineNumberRegex) { result ->
// replace line number with equivalent number of 'x' characters to keep formatting intact
(result.groups[1]!!.value) + "x".repeat(result.groups[3]!!.value.length) + " |"
}
protected fun String.stripWebsite() =
protected fun String.stripWebsite(): String =
replace(Release.current().documentation().homepage(), "https://\$pklWebsite/")
// can't think of a better solution right now
protected fun String.stripVersionCheckErrorMessage() =
protected fun String.stripVersionCheckErrorMessage(): String =
replace("Pkl version is ${Release.current().version()}", "Pkl version is xxx")
protected fun String.stripStdlibLocationSha(): String {
@@ -114,7 +114,7 @@ abstract class AbstractLanguageSnippetTestsEngine : InputOutputTestEngine() {
else Release.current().commitId()
return replace(
"https://github.com/apple/pkl/blob/${commitIsh}/stdlib/",
"https://github.com/apple/pkl/blob/\$commitId/stdlib/"
"https://github.com/apple/pkl/blob/\$commitId/stdlib/",
)
}
@@ -135,7 +135,7 @@ class LanguageSnippetTestsEngine : AbstractLanguageSnippetTestsEngine() {
"NAME2" to "value2",
"/foo/bar" to "foobar",
"foo bar" to "foo bar",
"file:///foo/bar" to "file:///foo/bar"
"file:///foo/bar" to "file:///foo/bar",
)
)
.setExternalProperties(
@@ -169,7 +169,7 @@ class LanguageSnippetTestsEngine : AbstractLanguageSnippetTestsEngine() {
SecurityManagers.defaultManager,
null,
StackFrameTransformers.empty,
mapOf()
mapOf(),
)
securityManager = null
applyFromProject(project)
@@ -200,13 +200,13 @@ abstract class AbstractNativeLanguageSnippetTestsEngine : AbstractLanguageSnippe
// on the other hand, don't exclude /native/
Regex(".*/import1b\\.pkl"),
// URIs get rendered slightly differently (percent-encoded vs raw)
Regex(".*日本語_error\\.pkl")
Regex(".*日本語_error\\.pkl"),
)
/** Avoid running tests for native binaries when those native binaries have not been built. */
override fun discover(
discoveryRequest: EngineDiscoveryRequest,
uniqueId: UniqueId
uniqueId: UniqueId,
): TestDescriptor {
if (!pklExecutablePath.exists()) {
// return empty descriptor w/o children

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -98,7 +98,7 @@ class TestExternalReaderProcess(private val transport: MessageTransport) : Exter
companion object {
fun initializeTestHarness(
moduleReaders: List<ExternalModuleReader>,
resourceReaders: List<ExternalResourceReader>
resourceReaders: List<ExternalResourceReader>,
): Pair<TestExternalReaderProcess, ExternalReaderRuntime> {
val rxIn = PipedInputStream(10240)
val rxOut = PipedOutputStream(rxIn)
@@ -108,14 +108,12 @@ class TestExternalReaderProcess(private val transport: MessageTransport) : Exter
MessageTransports.stream(
ExternalReaderMessagePackDecoder(rxIn),
ExternalReaderMessagePackEncoder(txOut),
{}
)
) {}
val clientTransport =
MessageTransports.stream(
ExternalReaderMessagePackDecoder(txIn),
ExternalReaderMessagePackEncoder(rxOut),
{}
)
) {}
val runtime = ExternalReaderRuntime(moduleReaders, resourceReaders, clientTransport)
val proc = TestExternalReaderProcess(serverTransport)

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,11 +18,11 @@ package org.pkl.core.module
import java.net.URI
import java.nio.file.Path
import kotlin.io.path.createDirectories
import kotlin.io.path.createParentDirectories
import kotlin.io.path.outputStream
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.toPath
import org.pkl.commons.writeString
import org.pkl.core.SecurityManagers

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,11 +21,11 @@ import java.net.URI
import java.net.URISyntaxException
import java.nio.file.Path
import kotlin.io.path.createFile
import kotlin.io.path.createParentDirectories
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.toPath
import org.pkl.commons.writeString
import org.pkl.core.SecurityManagers

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@ package org.pkl.core.packages
import java.io.FileNotFoundException
import java.io.IOException
import java.nio.charset.StandardCharsets
import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.deleteRecursively
import kotlin.io.path.exists
import kotlin.io.path.readBytes
import org.assertj.core.api.Assertions.assertThat
@@ -25,7 +27,6 @@ import org.assertj.core.api.Assertions.assertThatCode
import org.junit.jupiter.api.*
import org.junit.jupiter.api.parallel.Execution
import org.junit.jupiter.api.parallel.ExecutionMode
import org.pkl.commons.deleteRecursively
import org.pkl.commons.readString
import org.pkl.commons.test.FileTestUtils
import org.pkl.commons.test.PackageServer
@@ -118,7 +119,7 @@ class PackageResolversTest {
PathElement("catalog", true),
PathElement("Bird.pkl", false),
PathElement("allFruit.pkl", false),
PathElement("catalog.pkl", false)
PathElement("catalog.pkl", false),
)
)
}
@@ -129,13 +130,13 @@ class PackageResolversTest {
resolver.getBytes(
PackageAssetUri("package://localhost:0/birds@0.5.0#/Bird.pkl"),
false,
null
null,
)
val swallow =
resolver.getBytes(
PackageAssetUri("package://localhost:0/birds@0.5.0#/catalog/Swallow.pkl"),
false,
null
null,
)
assertThat(bird).isEqualTo(packageRoot.resolve("birds@0.5.0/package/Bird.pkl").readBytes())
assertThat(swallow)
@@ -150,12 +151,7 @@ class PackageResolversTest {
.listElements(PackageAssetUri("package://localhost:0/birds@0.5.0#/catalog/"), null)
.toSet()
assertThat(elements)
.isEqualTo(
setOf(
PathElement("Ostrich.pkl", false),
PathElement("Swallow.pkl", false),
)
)
.isEqualTo(setOf(PathElement("Ostrich.pkl", false), PathElement("Swallow.pkl", false)))
}
@Test
@@ -174,7 +170,7 @@ class PackageResolversTest {
.getBytes(
PackageAssetUri("package://localhost:0/not-a-package@0.5.0#/Horse.pkl"),
false,
null
null,
)
.toString(StandardCharsets.UTF_8)
}
@@ -186,7 +182,7 @@ class PackageResolversTest {
resolver.getBytes(
PackageAssetUri("package://localhost:0/badPackageZipUrl@1.0.0#/Bug.pkl"),
false,
null
null,
)
}
.hasMessage(
@@ -201,7 +197,7 @@ class PackageResolversTest {
resolver.getBytes(
PackageAssetUri("package://localhost:0/badChecksum@1.0.0#/Bug.pkl"),
false,
null
null,
)
}
assertThat(error)
@@ -215,6 +211,7 @@ class PackageResolversTest {
}
}
@ExperimentalPathApi
class DiskCachedPackageResolverTest : AbstractPackageResolverTest() {
private val cacheDir = FileTestUtils.rootProjectDir.resolve("pkl-core/build/test-cache")
@@ -233,7 +230,7 @@ class PackageResolversTest {
PackageResolvers.DiskCachedPackageResolver(
SecurityManagers.defaultManager,
httpClient,
cacheDir
cacheDir,
)
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,11 +17,11 @@ package org.pkl.core.settings
import java.net.URI
import java.nio.file.Path
import kotlin.io.path.createParentDirectories
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatCode
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.writeString
import org.pkl.core.Evaluator
import org.pkl.core.ModuleSource
@@ -71,7 +71,7 @@ class PklSettingsTest {
PklEvaluatorSettings.Http(
PklEvaluatorSettings.Proxy(
URI("http://localhost:8080"),
listOf("example.com", "pkg.pkl-lang.org")
listOf("example.com", "pkg.pkl-lang.org"),
)
)
assertThat(settings).isEqualTo(PklSettings(Editor.SYSTEM, expectedHttp))
@@ -95,12 +95,7 @@ class PklSettingsTest {
val settings = PklSettings.loadFromPklHomeDir(tempDir)
val expectedHttp =
PklEvaluatorSettings.Http(
PklEvaluatorSettings.Proxy(
URI("http://localhost:8080"),
listOf(),
)
)
PklEvaluatorSettings.Http(PklEvaluatorSettings.Proxy(URI("http://localhost:8080"), listOf()))
assertThat(settings).isEqualTo(PklSettings(Editor.SYSTEM, expectedHttp))
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,12 +20,12 @@ import java.net.URI
import java.net.URISyntaxException
import java.nio.file.Path
import kotlin.io.path.createFile
import kotlin.io.path.createParentDirectories
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatExceptionOfType
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.createParentDirectories
import org.pkl.commons.toPath
import org.pkl.core.SecurityManager
import org.pkl.core.module.ModuleKeyFactories
@@ -49,7 +49,7 @@ class IoUtilsTest {
ModuleKeyFactories.pkg,
ModuleKeyFactories.file,
ModuleKeyFactories.standardLibrary,
ModuleKeyFactories.genericUrl
ModuleKeyFactories.genericUrl,
)
)
@@ -174,7 +174,7 @@ class IoUtilsTest {
assertThat(
IoUtils.relativize(
URI("https://foo.com/bar/baz.pkl?query"),
URI("https://foo.com/bar/qux.pkl")
URI("https://foo.com/bar/qux.pkl"),
)
)
.isEqualTo(URI("baz.pkl?query"))
@@ -182,7 +182,7 @@ class IoUtilsTest {
assertThat(
IoUtils.relativize(
URI("https://foo.com/bar/baz.pkl#fragment"),
URI("https://foo.com/bar/qux.pkl")
URI("https://foo.com/bar/qux.pkl"),
)
)
.isEqualTo(URI("baz.pkl#fragment"))
@@ -190,7 +190,7 @@ class IoUtilsTest {
assertThat(
IoUtils.relativize(
URI("https://foo.com/bar/baz.pkl?query#fragment"),
URI("https://foo.com/bar/qux.pkl")
URI("https://foo.com/bar/qux.pkl"),
)
)
.isEqualTo(URI("baz.pkl?query#fragment"))
@@ -198,7 +198,7 @@ class IoUtilsTest {
assertThat(
IoUtils.relativize(
URI("https://foo.com/bar/baz.pkl?query#fragment"),
URI("https://foo.com/bar/qux.pkl?query2#fragment2")
URI("https://foo.com/bar/qux.pkl?query2#fragment2"),
)
)
.isEqualTo(URI("baz.pkl?query#fragment"))
@@ -211,7 +211,7 @@ class IoUtilsTest {
assertThat(
IoUtils.relativize(
URI("https://foo.com:80/bar/baz.pkl"),
URI("https://bar.com:80/bar/baz.pkl")
URI("https://bar.com:80/bar/baz.pkl"),
)
)
.isEqualTo(URI("https://foo.com:80/bar/baz.pkl"))
@@ -219,7 +219,7 @@ class IoUtilsTest {
assertThat(
IoUtils.relativize(
URI("https://foo:bar@foo.com:80/bar/baz.pkl"),
URI("https://foo:baz@bar.com:80/bar/baz.pkl")
URI("https://foo:baz@bar.com:80/bar/baz.pkl"),
)
)
.isEqualTo(URI("https://foo:bar@foo.com:80/bar/baz.pkl"))
@@ -282,7 +282,7 @@ class IoUtilsTest {
"modulepath:/foo.pkl" to "foo",
"modulepath:/foo/bar/baz.pkl" to "baz",
"package://example.com/foo/bar@1.0.0#/baz.pkl" to "baz",
"package://example.com/foo/bar@1.0.0#/baz/biz/qux.pkl" to "qux"
"package://example.com/foo/bar@1.0.0#/baz/biz/qux.pkl" to "qux",
)
for ((uriStr, name) in assertions) {
val uri = URI(uriStr)
@@ -356,7 +356,7 @@ class IoUtilsTest {
IoUtils.resolve(
FakeSecurityManager,
key,
URI(".../core/module/NamedModuleResolversTest.pkl")
URI(".../core/module/NamedModuleResolversTest.pkl"),
)
)
.isEqualTo(URI("modulepath:/org/pkl/core/module/NamedModuleResolversTest.pkl"))
@@ -365,7 +365,7 @@ class IoUtilsTest {
IoUtils.resolve(
FakeSecurityManager,
key,
URI(".../org/pkl/core/module/NamedModuleResolversTest.pkl")
URI(".../org/pkl/core/module/NamedModuleResolversTest.pkl"),
)
)
.isEqualTo(URI("modulepath:/org/pkl/core/module/NamedModuleResolversTest.pkl"))