Follow up for trace pretty printing (#1227)

This commit is contained in:
Jen Basch
2025-10-08 09:36:42 -07:00
committed by GitHub
parent cf9d87373d
commit e230fcf1a9
29 changed files with 186 additions and 119 deletions
@@ -1,5 +1,5 @@
amends "pkl:Project"
evaluatorSettings {
traceMode = "default"
traceMode = "compact"
}
@@ -1,5 +0,0 @@
amends "pkl:Project"
evaluatorSettings {
traceMode = "hidden"
}
@@ -1,18 +0,0 @@
amends ".../snippetTest.pkl"
examples {
["traceMode = 'hidden' results in no trace output"] {
trace(new {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
})
}
}
@@ -1,7 +1,51 @@
amends ".../snippetTest.pkl"
examples {
["traceMode = 'pretty' results in indented, multi-line output"] {
["single-line lhs, single-line rhs"] {
let (val = new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
})
trace(val["Parrot"].name)
}
["single-line lhs, multi-line rhs"] {
let (val = new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
})
trace(val)
}
["multi-line lhs, single-line rhs"] {
trace((new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
})["Parrot"].name)
}
["multi-line lhs, multi-line rhs"] {
trace(new {
["Parrot"] {
name = "Parrot"
@@ -25,4 +25,4 @@ pkl: TRACE: new {
}
}
}
} = new Dynamic { ["Parrot"] { name = "Parrot"; age = 1234; bucketSettings { kicked = true; ["fjordConfig"] { isPining = true } } } } (file:///$snippetsDir/input/projects/defaultTraceMode/defaultTraceMode.pkl)
} = new Dynamic { ["Parrot"] { name = "Parrot"; age = 1234; bucketSettings { kicked = true; ["fjordConfig"] { isPining = true } } } } (file:///$snippetsDir/input/projects/compactTraceMode/compactTraceMode.pkl)
@@ -1,16 +0,0 @@
examples {
["traceMode = 'hidden' results in no trace output"] {
new {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings {
kicked = true
["fjordConfig"] {
isPining = true
}
}
}
}
}
}
@@ -1,5 +1,25 @@
examples {
["traceMode = 'pretty' results in indented, multi-line output"] {
["single-line lhs, single-line rhs"] {
"Parrot"
}
["single-line lhs, multi-line rhs"] {
new {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings {
kicked = true
["fjordConfig"] {
isPining = true
}
}
}
}
}
["multi-line lhs, single-line rhs"] {
"Parrot"
}
["multi-line lhs, multi-line rhs"] {
new {
["Parrot"] {
name = "Parrot"
@@ -14,26 +34,61 @@ examples {
}
}
}
pkl: TRACE: new {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
pkl: TRACE: val["Parrot"].name = "Parrot"
(file:///$snippetsDir/input/projects/prettyTraceMode/prettyTraceMode.pkl)
pkl: TRACE: val =
new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings {
kicked = true
["fjordConfig"] {
isPining = true
}
}
} = new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings {
kicked = true
["fjordConfig"] {
isPining = true
}
}
}
} (file:///$snippetsDir/input/projects/prettyTraceMode/prettyTraceMode.pkl)
(file:///$snippetsDir/input/projects/prettyTraceMode/prettyTraceMode.pkl)
pkl: TRACE:
(new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
})["Parrot"].name
= "Parrot"
(file:///$snippetsDir/input/projects/prettyTraceMode/prettyTraceMode.pkl)
pkl: TRACE:
new {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings = new {
kicked = true
["fjordConfig"] = new {
isPining = true
}
}
}
}
=
new Dynamic {
["Parrot"] {
name = "Parrot"
age = 1234
bucketSettings {
kicked = true
["fjordConfig"] {
isPining = true
}
}
}
}
(file:///$snippetsDir/input/projects/prettyTraceMode/prettyTraceMode.pkl)
@@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
import org.pkl.commons.test.PackageServer
import org.pkl.commons.writeString
import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.http.HttpClient
import org.pkl.core.module.ModuleKeyFactories
import org.pkl.core.project.Project
@@ -37,7 +38,7 @@ class AnalyzerTest {
null,
null,
HttpClient.dummyClient(),
null,
TraceMode.COMPACT,
)
@Test
@@ -116,7 +117,7 @@ class AnalyzerTest {
tempDir.resolve("packages"),
null,
HttpClient.dummyClient(),
null,
TraceMode.COMPACT,
)
PackageServer.populateCacheDir(tempDir.resolve("packages"))
val file1 =
@@ -192,7 +193,7 @@ class AnalyzerTest {
tempDir.resolve("packages"),
project.dependencies,
HttpClient.dummyClient(),
null,
TraceMode.COMPACT,
)
val file1 =
tempDir
@@ -305,7 +306,7 @@ class AnalyzerTest {
tempDir.resolve("packages"),
project.dependencies,
HttpClient.dummyClient(),
null,
TraceMode.COMPACT,
)
val result = analyzer.importGraph(mainPkl.toUri())
val birdUri = URI("projectpackage://localhost:0/birds@1.0.0#/bird.pkl")
@@ -18,6 +18,7 @@ package org.pkl.core
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.pkl.commons.toPath
import org.pkl.core.evaluatorSettings.TraceMode
import org.pkl.core.http.HttpClient
import org.pkl.core.module.ModuleKeyFactories
import org.pkl.core.repl.ReplRequest
@@ -45,7 +46,7 @@ class ReplServerTest {
"/".toPath(),
StackFrameTransformers.defaultTransformer,
false,
null,
TraceMode.COMPACT,
)
@Test