Reformat Kotlin code (#1560)

ktfmt has much improved how it formats Kotlin code. Unfortunately, this
means that whenever we touch a single line in a Kotlin file, we get a
_lot_ more changes thanks to ratcheting now picking up this file for
formatting.

This PR just reformats every single Kotlin file so we don't have to deal
with this churn in future PRs that touch Kotlin code.
This commit is contained in:
Daniel Chao
2026-04-25 06:14:44 -07:00
committed by GitHub
parent c4f56bf20d
commit 2b3603b544
44 changed files with 2862 additions and 2848 deletions
@@ -44,19 +44,19 @@ constructor(
private val sourceModule =
ModuleSource.text(
"""
import "pkl:analyze"
import "pkl:analyze"
local importStrings = read*("prop:pkl.analyzeImports.**").toMap().values.toSet()
local importStrings = read*("prop:pkl.analyzeImports.**").toMap().values.toSet()
output {
value = analyze.importGraph(importStrings)
renderer {
converters {
[Map] = (it) -> it.toMapping()
[Set] = (it) -> it.toListing()
}
output {
value = analyze.importGraph(importStrings)
renderer {
converters {
[Map] = (it) -> it.toMapping()
[Set] = (it) -> it.toListing()
}
}
}
"""
.trimIndent()
)
@@ -53,9 +53,9 @@ constructor(
throw CliException(
"""
Usage: pkl test [<options>] <modules>...
Error: missing argument <modules>
"""
"""
.trimIndent()
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 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.
@@ -47,7 +47,7 @@ internal object ReplMessages {
* Incomplete input will be continued on the next line.
* Multi-line programs can be copy-pasted into the REPL.
"""
"""
.trimIndent()
val examples: String =
File diff suppressed because it is too large Load Diff
@@ -58,7 +58,7 @@ class CliEvaluatorTest {
name = "pigeon"
age = 20 + 10
}
"""
"""
.trimIndent()
private val packageServer = PackageServer()
@@ -243,12 +243,12 @@ person:
.resolve("test2.pkl")
.writeString(
"""
amends "test.pkl"
person {
name = "barn owl"
}
"""
amends "test.pkl"
person {
name = "barn owl"
}
"""
.trimIndent()
)
@@ -655,9 +655,9 @@ result = someLib.x
"output.pcf",
"""
x = 1
y = 2
z = 3
"""
.trimIndent(),
@@ -739,7 +739,7 @@ result = someLib.x
}
}
}
"""
"""
.trimIndent(),
)
)
@@ -815,31 +815,31 @@ result = someLib.x
writePklFile(
"test0.pkl",
"""
output {
files {
["foo.pcf"] {
value = new Dynamic {
["bar"] = "baz"
output {
files {
["foo.pcf"] {
value = new Dynamic {
["bar"] = "baz"
}
}
}
}
}
"""
"""
.trimIndent(),
),
writePklFile(
"test1.pkl",
"""
output {
files {
["bar.pcf"] {
value = new Dynamic {
["bar"] = "baz"
output {
files {
["bar.pcf"] {
value = new Dynamic {
["bar"] = "baz"
}
}
}
}
}
"""
"""
.trimIndent(),
),
)
@@ -860,27 +860,27 @@ result = someLib.x
writePklFile(
"bar.pkl",
"""
output {
files {
["foo.pcf"] {
text = "myBar"
output {
files {
["foo.pcf"] {
text = "myBar"
}
}
}
}
"""
"""
.trimIndent(),
),
writePklFile(
"foo.pkl",
"""
output {
files {
["foo.pcf"] {
text = "myFoo"
output {
files {
["foo.pcf"] {
text = "myFoo"
}
}
}
}
"""
"""
.trimIndent(),
),
)
@@ -918,7 +918,7 @@ result = someLib.x
}
}
}
"""
"""
.trimIndent(),
)
val options =
@@ -949,7 +949,7 @@ result = someLib.x
}
}
}
"""
"""
.trimIndent(),
)
val options =
@@ -970,23 +970,23 @@ result = someLib.x
writePklFile(
"test1.pkl",
"""
output {
files {
["."] { text = "bar" }
output {
files {
["."] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
),
writePklFile(
"test2.pkl",
"""
output {
files {
["myDir"] { text = "bar" }
output {
files {
["myDir"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
),
)
@@ -1009,23 +1009,23 @@ result = someLib.x
writePklFile(
"test1.pkl",
"""
output {
files {
["foo.txt"] { text = "bar" }
output {
files {
["foo.txt"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
),
writePklFile(
"test2.pkl",
"""
output {
files {
["foo.txt"] { text = "bar" }
output {
files {
["foo.txt"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
),
)
@@ -1045,13 +1045,13 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
output {
files {
["foo.txt"] { text = "bar" }
["./foo.txt"] { text = "bar" }
output {
files {
["foo.txt"] { text = "bar" }
["./foo.txt"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
)
val options =
@@ -1071,12 +1071,12 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
output {
files {
["foo:bar"] { text = "bar" }
output {
files {
["foo:bar"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
)
@@ -1096,12 +1096,12 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
output {
files {
["foo\\bar"] { text = "bar" }
output {
files {
["foo\\bar"] { text = "bar" }
}
}
}
"""
"""
.trimIndent(),
)
@@ -1120,10 +1120,10 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
foo {
bar = 1
}
"""
foo {
bar = 1
}
"""
.trimIndent(),
)
val options =
@@ -1136,8 +1136,8 @@ result = someLib.x
assertThat(buffer.toString(StandardCharsets.UTF_8))
.isEqualTo(
"""
new Dynamic { bar = 1 }
"""
new Dynamic { bar = 1 }
"""
.trimIndent()
)
}
@@ -1148,13 +1148,13 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
class Person {
name: String
class Person {
name: String
function toString() = "Person(\(name))"
}
person: Person = new { name = "Frodo" }
"""
function toString() = "Person(\(name))"
}
person: Person = new { name = "Frodo" }
"""
.trimIndent(),
)
val options =
@@ -1173,10 +1173,10 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
person {
friend { name = "Bilbo" }
}
"""
person {
friend { name = "Bilbo" }
}
"""
.trimIndent(),
)
val options =
@@ -1196,17 +1196,17 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
res = 1
"""
res = 1
"""
.trimIndent(),
)
writePklFile(
"PklProject",
"""
amends "pkl:Project"
package = throw("invalid project package")
"""
"""
.trimIndent(),
)
val options =
@@ -1225,8 +1225,8 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
res = read*("env:**")
"""
res = read*("env:**")
"""
.trimIndent(),
)
writePklFile(
@@ -1234,14 +1234,14 @@ result = someLib.x
// language=Pkl
"""
amends "pkl:Project"
evaluatorSettings {
env {
["foo"] = "foo"
["bar"] = "bar"
}
}
"""
"""
.trimIndent(),
)
val options =
@@ -1251,12 +1251,12 @@ result = someLib.x
assertThat(buffer.toString(StandardCharsets.UTF_8))
.isEqualTo(
"""
res {
["env:bar"] = "bar"
["env:foo"] = "foo"
}
"""
res {
["env:bar"] = "bar"
["env:foo"] = "foo"
}
"""
.trimIndent()
)
}
@@ -1353,10 +1353,10 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
import "package://localhost:0/birds@0.5.0#/catalog/Swallow.pkl"
res = Swallow
"""
import "package://localhost:0/birds@0.5.0#/catalog/Swallow.pkl"
res = Swallow
"""
.trimIndent(),
)
val buffer = ByteArrayOutputStream()
@@ -1375,14 +1375,14 @@ result = someLib.x
assertThat(buffer.toString(StandardCharsets.UTF_8))
.isEqualTo(
"""
res {
name = "Swallow"
favoriteFruit {
name = "Apple"
res {
name = "Swallow"
favoriteFruit {
name = "Apple"
}
}
}
"""
"""
.trimIndent()
)
assertThat(tempDir.resolve("package-2")).doesNotExist()
@@ -1481,13 +1481,13 @@ result = someLib.x
assertThat(output)
.isEqualTo(
"""
name = "Ostrich"
name = "Ostrich"
favoriteFruit {
name = "Orange"
}
favoriteFruit {
name = "Orange"
}
"""
"""
.trimIndent()
)
verify(getRequestedFor(urlEqualTo("birds@0.5.0")))
@@ -1590,13 +1590,13 @@ result = someLib.x
homeDir.writeFile(
"settings.pkl",
"""
amends "pkl:settings"
amends "pkl:settings"
http {
proxy {
address = "http://invalid.proxy.address"
}
http {
proxy {
address = "http://invalid.proxy.address"
}
}
"""
.trimIndent(),
)
@@ -1677,26 +1677,26 @@ result = someLib.x
writePklFile(
"test.pkl",
"""
pigeon {
name = "Pigeon"
diet = "Seeds"
}
parrot {
name = "Parrot"
diet = "Seeds"
}
output {
files {
["pigeon.json"] {
value = pigeon
renderer = new JsonRenderer {}
}
["birds/parrot.yaml"] {
value = parrot
renderer = new YamlRenderer {}
}
pigeon {
name = "Pigeon"
diet = "Seeds"
}
parrot {
name = "Parrot"
diet = "Seeds"
}
output {
files {
["pigeon.json"] {
value = pigeon
renderer = new JsonRenderer {}
}
["birds/parrot.yaml"] {
value = parrot
renderer = new YamlRenderer {}
}
}
}
"""
.trimIndent(),
)
@@ -1713,10 +1713,10 @@ result = someLib.x
realOutputDir.resolve("pigeon.json"),
"pigeon.json",
"""
{
"name": "Pigeon",
"diet": "Seeds"
}
{
"name": "Pigeon",
"diet": "Seeds"
}
"""
.trimIndent(),
)
@@ -1725,8 +1725,8 @@ result = someLib.x
realOutputDir.resolve("birds/parrot.yaml"),
"parrot.yaml",
"""
name: Parrot
diet: Seeds
name: Parrot
diet: Seeds
"""
.trimIndent(),
)
@@ -1735,10 +1735,10 @@ result = someLib.x
symlinkOutputDir.resolve("pigeon.json"),
"pigeon.json",
"""
{
"name": "Pigeon",
"diet": "Seeds"
}
{
"name": "Pigeon",
"diet": "Seeds"
}
"""
.trimIndent(),
)
@@ -1747,8 +1747,8 @@ result = someLib.x
symlinkOutputDir.resolve("birds/parrot.yaml"),
"parrot.yaml",
"""
name: Parrot
diet: Seeds
name: Parrot
diet: Seeds
"""
.trimIndent(),
)
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 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.
@@ -69,12 +69,12 @@ class CliMainTest {
val code =
"""
x = 3
output {
value = x
renderer = new JsonRenderer {}
}
"""
"""
.trimIndent()
val inputFile = tempDir.resolve("test.pkl").writeString(code).toString()
val outputFile = makeSymdir(tempDir, "out", "linkOut").resolve("test.pkl").toString()
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 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.
@@ -70,11 +70,11 @@ class CliPackageDownloaderTest {
"PklProject",
"""
amends "pkl:Project"
evaluatorSettings {
moduleCacheDir = ".my-cache"
}
"""
"""
.trimIndent(),
)
@@ -210,7 +210,7 @@ class CliPackageDownloaderTest {
Exception when making request `GET https://bogus.domain/notAPackage@1.0.0`:
Error connecting to host `bogus.domain`.
"""
"""
.trimIndent()
)
}
@@ -1,5 +1,5 @@
/*
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2026 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.
@@ -85,8 +85,8 @@ class CliProjectPackagerTest {
.resolve("PklProject")
.writeString(
"""
amends "pkl:Project"
"""
amends "pkl:Project"
"""
.trimIndent()
)
val packager =
@@ -108,20 +108,20 @@ class CliProjectPackagerTest {
"myTest.pkl",
"""
amends "pkl:test"
facts {
["1 == 2"] {
1 == 2
}
}
"""
"""
.trimIndent(),
)
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
@@ -129,7 +129,7 @@ class CliProjectPackagerTest {
packageZipUrl = "https://foo.com"
apiTests { "myTest.pkl" }
}
"""
"""
.trimIndent(),
)
val buffer = StringWriter()
@@ -154,13 +154,13 @@ class CliProjectPackagerTest {
.writeString(
"""
amends "pkl:test"
facts {
["1 == 1"] {
1 == 1
}
}
"""
"""
.trimIndent()
)
tempDir
@@ -168,7 +168,7 @@ class CliProjectPackagerTest {
.writeString(
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
@@ -176,7 +176,7 @@ class CliProjectPackagerTest {
packageZipUrl = "https://foo.com"
apiTests { "myTest.pkl" }
}
"""
"""
.trimIndent()
)
val buffer = StringWriter()
@@ -203,13 +203,13 @@ class CliProjectPackagerTest {
"""
amends "pkl:test"
import "@birds/Bird.pkl"
examples {
["Bird"] {
new Bird { name = "Finch"; favoriteFruit { name = "Tangerine" } }
}
}
"""
"""
.trimIndent()
)
projectDir
@@ -226,8 +226,8 @@ class CliProjectPackagerTest {
}
}
}
"""
"""
.trimIndent()
)
projectDir
@@ -235,7 +235,7 @@ class CliProjectPackagerTest {
.writeString(
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
@@ -249,7 +249,7 @@ class CliProjectPackagerTest {
uri = "package://localhost:0/birds@0.5.0"
}
}
"""
"""
.trimIndent()
)
projectDir
@@ -298,9 +298,9 @@ class CliProjectPackagerTest {
"a/b/foo.pkl",
"""
module foo
name: String
"""
"""
.trimIndent(),
)
@@ -311,7 +311,7 @@ class CliProjectPackagerTest {
foo
bar
baz
"""
"""
.trimIndent(),
)
@@ -320,14 +320,14 @@ class CliProjectPackagerTest {
.writeString(
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
"""
.trimIndent()
)
val packager =
@@ -348,18 +348,18 @@ class CliProjectPackagerTest {
assertThat(expectedMetadata)
.hasContent(
"""
{
"name": "mypackage",
"packageUri": "package://example.com/mypackage@1.0.0",
"version": "1.0.0",
"packageZipUrl": "https://foo.com",
"packageZipChecksums": {
"sha256": "e83b67722ea17ba41717ce6e99ae8ee02d66df6294bd319ce403075b1071c3e0"
},
"dependencies": {},
"authors": []
}
"""
{
"name": "mypackage",
"packageUri": "package://example.com/mypackage@1.0.0",
"version": "1.0.0",
"packageZipUrl": "https://foo.com",
"packageZipChecksums": {
"sha256": "e83b67722ea17ba41717ce6e99ae8ee02d66df6294bd319ce403075b1071c3e0"
},
"dependencies": {},
"authors": []
}
"""
.trimIndent()
)
assertThat(expectedArchive).exists()
@@ -395,21 +395,21 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
exclude {
"*.bin"
"child/main.pkl"
"*.test.pkl"
"examples/Ex1.pkl"
"tests/**"
}
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
exclude {
"*.bin"
"child/main.pkl"
"*.test.pkl"
"examples/Ex1.pkl"
"tests/**"
}
}
"""
.trimIndent(),
)
@@ -444,21 +444,21 @@ class CliProjectPackagerTest {
projectDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
}
"""
.trimIndent(),
)
@@ -489,24 +489,24 @@ class CliProjectPackagerTest {
project2Dir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/project2"
version = "5.0.0"
packageZipUrl = "https://foo.com/project2.zip"
}
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/project2"
version = "5.0.0"
packageZipUrl = "https://foo.com/project2.zip"
}
"""
.trimIndent(),
)
project2Dir.writeFile(
"PklProject.deps.json",
"""
{
"schemaVersion": 1,
"resolvedDependencies": {}
}
{
"schemaVersion": 1,
"resolvedDependencies": {}
}
"""
.trimIndent(),
)
@@ -557,18 +557,18 @@ class CliProjectPackagerTest {
assertThat(project2Metadata.readString())
.isEqualTo(
"""
{
"name": "project2",
"packageUri": "package://localhost:0/project2@5.0.0",
"version": "5.0.0",
"packageZipUrl": "https://foo.com/project2.zip",
"packageZipChecksums": {
"sha256": "8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85"
},
"dependencies": {},
"authors": []
}
"""
{
"name": "project2",
"packageUri": "package://localhost:0/project2@5.0.0",
"version": "5.0.0",
"packageZipUrl": "https://foo.com/project2.zip",
"packageZipChecksums": {
"sha256": "8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85"
},
"dependencies": {},
"authors": []
}
"""
.trimIndent()
)
}
@@ -582,44 +582,44 @@ class CliProjectPackagerTest {
projectDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
}
"""
.trimIndent(),
)
projectDir.writeFile(
"PklProject.deps.json",
"""
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "projectpackage://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "0a5ad2dc13f06f73f96ba94e8d01d48252bc934e2de71a837620ca0fef8a7453"
}
},
"package://localhost:0/project2@5": {
"type": "local",
"uri": "projectpackage://localhost:0/project2@5.0.0",
"path": "../project2"
{
"schemaVersion": 1,
"resolvedDependencies": {
"package://localhost:0/birds@0": {
"type": "remote",
"uri": "projectpackage://localhost:0/birds@0.5.0",
"checksums": {
"sha256": "0a5ad2dc13f06f73f96ba94e8d01d48252bc934e2de71a837620ca0fef8a7453"
}
},
"package://localhost:0/project2@5": {
"type": "local",
"uri": "projectpackage://localhost:0/project2@5.0.0",
"path": "../project2"
}
}
}
"""
.trimIndent(),
)
@@ -627,24 +627,24 @@ class CliProjectPackagerTest {
project2Dir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/project2"
version = "5.0.0"
packageZipUrl = "https://foo.com/project2.zip"
}
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/project2"
version = "5.0.0"
packageZipUrl = "https://foo.com/project2.zip"
}
"""
.trimIndent(),
)
project2Dir.writeFile(
"PklProject.deps.json",
"""
{
"schemaVersion": 1,
"resolvedDependencies": {}
}
{
"schemaVersion": 1,
"resolvedDependencies": {}
}
"""
.trimIndent(),
)
@@ -667,23 +667,23 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"main.pkl",
"""
import "../foo.pkl"
res = foo
import "../foo.pkl"
res = foo
"""
.trimIndent(),
)
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -702,12 +702,12 @@ class CliProjectPackagerTest {
assertThat(e.message)
.startsWith(
"""
–– Pkl Error ––
Path `../foo.pkl` includes path segments that are outside the project root directory.
1 | import "../foo.pkl"
^^^^^^^^^^^^
"""
–– Pkl Error ––
Path `../foo.pkl` includes path segments that are outside the project root directory.
1 | import "../foo.pkl"
^^^^^^^^^^^^
"""
.trimIndent()
)
}
@@ -730,14 +730,14 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -776,14 +776,14 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -814,21 +814,21 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"foo/bar.pkl",
"""
import "baz.pkl"
import "baz.pkl"
"""
.trimIndent(),
)
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -849,14 +849,14 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"project1/PklProject",
"""
amends "pkl:Project"
package {
name = "project1"
version = "1.0.0"
baseUri = "package://example.com/project1"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "project1"
version = "1.0.0"
baseUri = "package://example.com/project1"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -864,14 +864,14 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"project2/PklProject",
"""
amends "pkl:Project"
package {
name = "project2"
version = "2.0.0"
baseUri = "package://example.com/project2"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "project2"
version = "2.0.0"
baseUri = "package://example.com/project2"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -914,14 +914,14 @@ class CliProjectPackagerTest {
"project/PklProject",
// intentionally conflict with localhost:0/birds@0.5.0 from our test fixtures
"""
amends "pkl:Project"
package {
name = "birds"
version = "0.5.0"
baseUri = "package://localhost:0/birds"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "birds"
version = "0.5.0"
baseUri = "package://localhost:0/birds"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -959,14 +959,14 @@ class CliProjectPackagerTest {
tempDir.writeFile(
"project/PklProject",
"""
amends "pkl:Project"
package {
name = "mangos"
version = "1.0.0"
baseUri = "package://localhost:0/mangos"
packageZipUrl = "https://foo.com"
}
amends "pkl:Project"
package {
name = "mangos"
version = "1.0.0"
baseUri = "package://localhost:0/mangos"
packageZipUrl = "https://foo.com"
}
"""
.trimIndent(),
)
@@ -1008,14 +1008,14 @@ class CliProjectPackagerTest {
@Deprecated { since = "0.26.1"; message = "do not use" }
@ModuleInfo { minPklVersion = "0.26.0" }
amends "pkl:Project"
package {
name = "mypackage"
version = "1.0.0"
baseUri = "package://example.com/mypackage"
packageZipUrl = "https://foo.com"
}
"""
"""
.trimIndent()
)
val packager =
@@ -1033,53 +1033,53 @@ class CliProjectPackagerTest {
assertThat(expectedMetadata)
.hasContent(
"""
{
"name": "mypackage",
"packageUri": "package://example.com/mypackage@1.0.0",
"version": "1.0.0",
"packageZipUrl": "https://foo.com",
"packageZipChecksums": {
"sha256": "8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85"
},
"dependencies": {},
"authors": [],
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Unlisted",
"moduleUri": "pkl:base"
},
"properties": {}
{
"name": "mypackage",
"packageUri": "package://example.com/mypackage@1.0.0",
"version": "1.0.0",
"packageZipUrl": "https://foo.com",
"packageZipChecksums": {
"sha256": "8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85"
},
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Deprecated",
"moduleUri": "pkl:base"
"dependencies": {},
"authors": [],
"annotations": [
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Unlisted",
"moduleUri": "pkl:base"
},
"properties": {}
},
"properties": {
"since": "0.26.1",
"message": "do not use",
"replaceWith": null
}
},
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "ModuleInfo",
"moduleUri": "pkl:base"
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "Deprecated",
"moduleUri": "pkl:base"
},
"properties": {
"since": "0.26.1",
"message": "do not use",
"replaceWith": null
}
},
"properties": {
"minPklVersion": "0.26.0"
{
"type": "PObject",
"classInfo": {
"moduleName": "pkl.base",
"class": "ModuleInfo",
"moduleUri": "pkl:base"
},
"properties": {
"minPklVersion": "0.26.0"
}
}
}
]
}
"""
]
}
"""
.trimIndent()
)
}
@@ -74,13 +74,13 @@ class CliProjectResolverTest {
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
}
"""
.trimIndent(),
)
@@ -129,13 +129,13 @@ class CliProjectResolverTest {
tempDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
}
"""
.trimIndent(),
)
@@ -185,35 +185,35 @@ class CliProjectResolverTest {
projectDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["project2"] = import("../project2/PklProject")
}
"""
.trimIndent(),
)
projectDir.writeFile(
"../project2/PklProject",
"""
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/package2"
version = "5.0.0"
packageZipUrl = "https://foo.com/package2.zip"
}
dependencies {
["fruit"] {
uri = "package://localhost:0/fruit@1.0.5"
}
["project3"] = import("../project3/PklProject")
amends "pkl:Project"
package {
name = "project2"
baseUri = "package://localhost:0/package2"
version = "5.0.0"
packageZipUrl = "https://foo.com/package2.zip"
}
dependencies {
["fruit"] {
uri = "package://localhost:0/fruit@1.0.5"
}
["project3"] = import("../project3/PklProject")
}
"""
.trimIndent(),
)
@@ -221,20 +221,20 @@ class CliProjectResolverTest {
projectDir.writeFile(
"../project3/PklProject",
"""
amends "pkl:Project"
package {
name = "project3"
baseUri = "package://localhost:0/package3"
version = "5.0.0"
packageZipUrl = "https://foo.com/package3.zip"
}
dependencies {
["fruit"] {
uri = "package://localhost:0/fruit@1.1.0"
}
amends "pkl:Project"
package {
name = "project3"
baseUri = "package://localhost:0/package3"
version = "5.0.0"
packageZipUrl = "https://foo.com/package3.zip"
}
dependencies {
["fruit"] {
uri = "package://localhost:0/fruit@1.1.0"
}
}
"""
.trimIndent(),
)
@@ -293,28 +293,28 @@ class CliProjectResolverTest {
projectDir.writeFile(
"PklProject",
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["fruit"] = import("../fruit/PklProject")
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
["fruit"] = import("../fruit/PklProject")
}
"""
.trimIndent(),
)
projectDir.writeFile(
"../fruit/PklProject",
"""
amends "pkl:Project"
package {
name = "fruit"
baseUri = "package://localhost:0/fruit"
version = "1.0.0"
packageZipUrl = "https://foo.com/fruit.zip"
}
amends "pkl:Project"
package {
name = "fruit"
baseUri = "package://localhost:0/fruit"
version = "1.0.0"
packageZipUrl = "https://foo.com/fruit.zip"
}
"""
.trimIndent(),
)
@@ -375,7 +375,7 @@ class CliProjectResolverTest {
uri = "package://localhost:0/birds@0.5.0"
}
}
"""
"""
.trimIndent(),
)
@@ -389,7 +389,7 @@ class CliProjectResolverTest {
uri = "package://localhost:0/fruit@1.1.0"
}
}
"""
"""
.trimIndent(),
)
@@ -469,14 +469,14 @@ class CliProjectResolverTest {
.resolve("PklProject")
.writeString(
"""
amends "pkl:Project"
amends "pkl:Project"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
dependencies {
["birds"] {
uri = "package://localhost:0/birds@0.5.0"
}
}
}
"""
"""
.trimIndent()
)
// coerce an IOException by making this a directory
@@ -47,7 +47,7 @@ class CliTestRunnerTest {
3 == 3
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val out = StringWriter()
@@ -65,13 +65,13 @@ class CliTestRunnerTest {
assertThat(out.toString().stripFileAndLines(tempDir))
.isEqualTo(
"""
module test
facts
✔ succeed
100.0% tests pass [1 passed], 100.0% asserts pass [2 passed]
module test
facts
✔ succeed
"""
100.0% tests pass [1 passed], 100.0% asserts pass [2 passed]
"""
.trimIndent()
)
assertThat(err.toString()).isEqualTo("")
@@ -89,7 +89,7 @@ class CliTestRunnerTest {
1 == 5
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val out = StringWriter()
@@ -136,7 +136,7 @@ class CliTestRunnerTest {
throw("uh oh")
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val out = StringWriter()
@@ -154,19 +154,19 @@ class CliTestRunnerTest {
assertThat(out.toString().stripFileAndLines(tempDir))
.isEqualToNormalizingNewlines(
"""
module test
facts
✘ fail
–– Pkl Error ––
uh oh
module test
facts
✘ fail
–– Pkl Error ––
uh oh
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#facts["fail"][#1] (/tempDir/test.pkl, line xx)
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#facts["fail"][#1] (/tempDir/test.pkl, line xx)
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
"""
"""
.trimIndent()
)
assertThat(err.toString()).isEqualTo("")
@@ -183,7 +183,7 @@ class CliTestRunnerTest {
throw("uh oh")
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val out = StringWriter()
@@ -201,19 +201,19 @@ class CliTestRunnerTest {
assertThat(out.toString().stripFileAndLines(tempDir))
.isEqualTo(
"""
module test
examples
✘ fail
–– Pkl Error ––
uh oh
module test
examples
✘ fail
–– Pkl Error ––
uh oh
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#examples["fail"][#1] (/tempDir/test.pkl, line xx)
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#examples["fail"][#1] (/tempDir/test.pkl, line xx)
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
"""
"""
.trimIndent()
)
assertThat(err.toString()).isEqualTo("")
@@ -232,19 +232,19 @@ class CliTestRunnerTest {
throw("uh oh")
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
tempDir
.resolve("test.pkl-expected.pcf")
.writeString(
"""
examples {
["fail"] {
"never compared to"
examples {
["fail"] {
"never compared to"
}
}
}
"""
"""
.trimIndent()
)
val out = StringWriter()
@@ -262,19 +262,19 @@ class CliTestRunnerTest {
assertThat(out.toString().stripFileAndLines(tempDir))
.isEqualToNormalizingNewlines(
"""
module test
examples
✘ fail
–– Pkl Error ––
uh oh
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#examples["fail"][#1] (/tempDir/test.pkl, line xx)
module test
examples
✘ fail
–– Pkl Error ––
uh oh
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
5 | throw("uh oh")
^^^^^^^^^^^^^^
at test#examples["fail"][#1] (/tempDir/test.pkl, line xx)
"""
0.0% tests pass [1/1 failed], 0.0% asserts pass [1/1 failed]
"""
.trimIndent()
)
assertThat(err.toString()).isEqualTo("")
@@ -296,7 +296,7 @@ class CliTestRunnerTest {
5 == 9
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val noopWriter = noopWriter()
@@ -314,19 +314,19 @@ class CliTestRunnerTest {
assertThat(junitReport)
.isEqualTo(
"""
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="test" tests="2" failures="1">
<testcase classname="test.facts" name="foo"></testcase>
<testcase classname="test.facts" name="bar">
<failure message="Fact Failure">5 == 9 (/tempDir/test.pkl, line xx)
false</failure>
</testcase>
<system-err><![CDATA[9 = 9
]]></system-err>
</testsuite>
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="test" tests="2" failures="1">
<testcase classname="test.facts" name="foo"></testcase>
<testcase classname="test.facts" name="bar">
<failure message="Fact Failure">5 == 9 (/tempDir/test.pkl, line xx)
false</failure>
</testcase>
<system-err><![CDATA[9 = 9
]]></system-err>
</testsuite>
"""
"""
.trimIndent()
)
}
@@ -346,7 +346,7 @@ class CliTestRunnerTest {
throw("uh oh")
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val noopWriter = noopWriter()
@@ -364,23 +364,23 @@ class CliTestRunnerTest {
assertThat(junitReport)
.isEqualTo(
"""
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="test" tests="2" failures="1">
<testcase classname="test.facts" name="foo"></testcase>
<testcase classname="test.facts" name="fail">
<error message="uh oh">–– Pkl Error ––
uh oh
9 | throw(&quot;uh oh&quot;)
^^^^^^^^^^^^^^
at test#facts[&quot;fail&quot;][#1] (/tempDir/test.pkl, line xx)
</error>
</testcase>
<system-err><![CDATA[9 = 9
]]></system-err>
</testsuite>
"""
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="test" tests="2" failures="1">
<testcase classname="test.facts" name="foo"></testcase>
<testcase classname="test.facts" name="fail">
<error message="uh oh">–– Pkl Error ––
uh oh
9 | throw(&quot;uh oh&quot;)
^^^^^^^^^^^^^^
at test#facts[&quot;fail&quot;][#1] (/tempDir/test.pkl, line xx)
</error>
</testcase>
<system-err><![CDATA[9 = 9
]]></system-err>
</testsuite>
"""
.trimIndent()
)
}
@@ -390,7 +390,7 @@ class CliTestRunnerTest {
val foo =
"""
module foo
amends "pkl:test"
facts {
@@ -398,13 +398,13 @@ class CliTestRunnerTest {
1 == 1
}
}
"""
"""
.trimIndent()
val bar =
"""
module foo
amends "pkl:test"
facts {
@@ -412,7 +412,7 @@ class CliTestRunnerTest {
1 == 1
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(foo).toString()
val input2 = tempDir.resolve("test.pkl").writeString(bar).toString()
@@ -438,7 +438,7 @@ class CliTestRunnerTest {
true
}
}
"""
"""
.trimIndent()
val code2 =
@@ -450,7 +450,7 @@ class CliTestRunnerTest {
true
}
}
"""
"""
.trimIndent()
val input1 = tempDir.resolve("test1.pkl").writeString(code1).toString()
val input2 = tempDir.resolve("test2.pkl").writeString(code2).toString()
@@ -482,7 +482,7 @@ class CliTestRunnerTest {
5 == 9
}
}
"""
"""
.trimIndent()
val code2 =
@@ -500,7 +500,7 @@ class CliTestRunnerTest {
true
}
}
"""
"""
.trimIndent()
val input1 = tempDir.resolve("test1.pkl").writeString(code1).toString()
val input2 = tempDir.resolve("test2.pkl").writeString(code2).toString()
@@ -547,7 +547,7 @@ class CliTestRunnerTest {
</testsuite>
</testsuites>
"""
"""
.trimIndent()
)
}
@@ -563,7 +563,7 @@ class CliTestRunnerTest {
true
}
}
"""
"""
.trimIndent()
val code2 =
@@ -575,7 +575,7 @@ class CliTestRunnerTest {
true
}
}
"""
"""
.trimIndent()
val input1 = tempDir.resolve("test1.pkl").writeString(code1).toString()
val input2 = tempDir.resolve("test2.pkl").writeString(code2).toString()
@@ -620,19 +620,19 @@ class CliTestRunnerTest {
2
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
tempDir
.resolve("test.pkl-expected.pcf")
.writeString(
"""
examples {
["nums"] {
1
examples {
["nums"] {
1
}
}
}
"""
"""
.trimIndent()
)
val out = StringWriter()
@@ -676,7 +676,7 @@ class CliTestRunnerTest {
2
}
}
"""
"""
.trimIndent()
val input = tempDir.resolve("test.pkl").writeString(code).toString()
val out = StringWriter()
@@ -694,13 +694,13 @@ class CliTestRunnerTest {
assertThat(out.toString())
.isEqualTo(
"""
module test
examples
✍️ nums
module test
examples
✍️ nums
1 examples written
"""
1 examples written
"""
.trimIndent()
)
}
@@ -738,13 +738,13 @@ class CliTestRunnerTest {
assertThat(out.toString().stripFileAndLines(tempDir))
.isEqualTo(
"""
module test
facts
✔ localeTest
module test
facts
✔ localeTest
100.0% tests pass [1 passed], 100.0% asserts pass [1 passed]
100.0% tests pass [1 passed], 100.0% asserts pass [1 passed]
"""
"""
.trimIndent()
)
assertThat(err.toString()).isEqualTo("")