mirror of
https://github.com/apple/pkl.git
synced 2026-04-23 00:38:37 +02:00
Adds traceMode evaluator setting to support trace() pretty printing (#1100)
This commit is contained in:
@@ -22,6 +22,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.graalvm.polyglot.Context;
|
||||
import org.pkl.core.evaluatorSettings.TraceMode;
|
||||
import org.pkl.core.http.HttpClient;
|
||||
import org.pkl.core.http.HttpClientInitException;
|
||||
import org.pkl.core.module.ModuleKeyFactory;
|
||||
@@ -46,6 +47,7 @@ public class Analyzer {
|
||||
private final @Nullable DeclaredDependencies projectDependencies;
|
||||
private final ModuleResolver moduleResolver;
|
||||
private final HttpClient httpClient;
|
||||
private final TraceMode traceMode;
|
||||
|
||||
public Analyzer(
|
||||
StackFrameTransformer transformer,
|
||||
@@ -54,7 +56,8 @@ public class Analyzer {
|
||||
Collection<ModuleKeyFactory> moduleKeyFactories,
|
||||
@Nullable Path moduleCacheDir,
|
||||
@Nullable DeclaredDependencies projectDependencies,
|
||||
HttpClient httpClient) {
|
||||
HttpClient httpClient,
|
||||
@Nullable TraceMode traceMode) {
|
||||
this.transformer = transformer;
|
||||
this.color = color;
|
||||
this.securityManager = securityManager;
|
||||
@@ -62,6 +65,7 @@ public class Analyzer {
|
||||
this.projectDependencies = projectDependencies;
|
||||
this.moduleResolver = new ModuleResolver(moduleKeyFactories);
|
||||
this.httpClient = httpClient;
|
||||
this.traceMode = traceMode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +119,8 @@ public class Analyzer {
|
||||
projectDependencies == null
|
||||
? null
|
||||
: new ProjectDependenciesManager(
|
||||
projectDependencies, moduleResolver, securityManager)));
|
||||
projectDependencies, moduleResolver, securityManager),
|
||||
traceMode));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import org.pkl.core.SecurityManagers.StandardBuilder;
|
||||
import org.pkl.core.evaluatorSettings.PklEvaluatorSettings.ExternalReader;
|
||||
import org.pkl.core.evaluatorSettings.TraceMode;
|
||||
import org.pkl.core.externalreader.ExternalReaderProcess;
|
||||
import org.pkl.core.http.HttpClient;
|
||||
import org.pkl.core.module.ModuleKeyFactories;
|
||||
@@ -67,6 +68,8 @@ public final class EvaluatorBuilder {
|
||||
|
||||
private @Nullable DeclaredDependencies dependencies;
|
||||
|
||||
private @Nullable TraceMode traceMode;
|
||||
|
||||
private EvaluatorBuilder() {}
|
||||
|
||||
/**
|
||||
@@ -454,6 +457,17 @@ public final class EvaluatorBuilder {
|
||||
return this.dependencies;
|
||||
}
|
||||
|
||||
/** Sets whether calls to trace() produce indented, multi-line output. */
|
||||
public EvaluatorBuilder setTraceMode(TraceMode traceMode) {
|
||||
this.traceMode = traceMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Returns whether calls to trace() produce indented, multi-line output. */
|
||||
public TraceMode getTraceMode() {
|
||||
return this.traceMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a project, sets its dependencies, and also applies any evaluator settings if set.
|
||||
*
|
||||
@@ -517,6 +531,7 @@ public final class EvaluatorBuilder {
|
||||
procs.computeIfAbsent(entry.getValue(), ExternalReaderProcess::of)));
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.http() != null) {
|
||||
var httpClientBuilder = HttpClient.builder();
|
||||
if (settings.http().proxy() != null) {
|
||||
@@ -531,6 +546,11 @@ public final class EvaluatorBuilder {
|
||||
}
|
||||
setHttpClient(httpClientBuilder.buildLazily());
|
||||
}
|
||||
|
||||
if (settings.traceMode() != null) {
|
||||
setTraceMode(settings.traceMode());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -557,6 +577,7 @@ public final class EvaluatorBuilder {
|
||||
timeout,
|
||||
moduleCacheDir,
|
||||
dependencies,
|
||||
outputFormat);
|
||||
outputFormat,
|
||||
traceMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.function.Supplier;
|
||||
import org.graalvm.polyglot.Context;
|
||||
import org.pkl.core.ast.ConstantValueNode;
|
||||
import org.pkl.core.ast.internal.ToStringNodeGen;
|
||||
import org.pkl.core.evaluatorSettings.TraceMode;
|
||||
import org.pkl.core.http.HttpClient;
|
||||
import org.pkl.core.module.ModuleKeyFactory;
|
||||
import org.pkl.core.module.ProjectDependenciesManager;
|
||||
@@ -80,7 +81,8 @@ public class EvaluatorImpl implements Evaluator {
|
||||
@Nullable Duration timeout,
|
||||
@Nullable Path moduleCacheDir,
|
||||
@Nullable DeclaredDependencies projectDependencies,
|
||||
@Nullable String outputFormat) {
|
||||
@Nullable String outputFormat,
|
||||
@Nullable TraceMode traceMode) {
|
||||
|
||||
securityManager = manager;
|
||||
frameTransformer = transformer;
|
||||
@@ -108,7 +110,8 @@ public class EvaluatorImpl implements Evaluator {
|
||||
projectDependencies == null
|
||||
? null
|
||||
: new ProjectDependenciesManager(
|
||||
projectDependencies, moduleResolver, securityManager)));
|
||||
projectDependencies, moduleResolver, securityManager),
|
||||
traceMode));
|
||||
});
|
||||
this.timeout = timeout;
|
||||
// NOTE: would probably make sense to share executor between evaluators
|
||||
|
||||
@@ -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.
|
||||
@@ -19,12 +19,17 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
||||
import com.oracle.truffle.api.frame.VirtualFrame;
|
||||
import com.oracle.truffle.api.source.SourceSection;
|
||||
import org.pkl.core.ast.ExpressionNode;
|
||||
import org.pkl.core.evaluatorSettings.TraceMode;
|
||||
import org.pkl.core.runtime.*;
|
||||
|
||||
public final class TraceNode extends ExpressionNode {
|
||||
@Child private ExpressionNode valueNode;
|
||||
|
||||
private final VmValueRenderer renderer = VmValueRenderer.singleLine(1000000);
|
||||
private static final int MAX_RENDERER_LENGTH = 1000000;
|
||||
|
||||
private final VmValueRenderer singleLineRenderer =
|
||||
VmValueRenderer.singleLine(MAX_RENDERER_LENGTH);
|
||||
private final VmValueRenderer multiLineRenderer = VmValueRenderer.multiLine(MAX_RENDERER_LENGTH);
|
||||
|
||||
public TraceNode(SourceSection sourceSection, ExpressionNode valueNode) {
|
||||
super(sourceSection);
|
||||
@@ -40,6 +45,10 @@ public final class TraceNode extends ExpressionNode {
|
||||
|
||||
@TruffleBoundary
|
||||
private void doTrace(Object value, VmContext context) {
|
||||
// If traces are disabled, returns early.
|
||||
if (context.getTraceMode() == TraceMode.HIDDEN) {
|
||||
return;
|
||||
}
|
||||
if (value instanceof VmObjectLike objectLike) {
|
||||
try {
|
||||
objectLike.force(true, true);
|
||||
@@ -48,7 +57,12 @@ public final class TraceNode extends ExpressionNode {
|
||||
}
|
||||
|
||||
var sourceSection = valueNode.getSourceSection();
|
||||
var renderedValue = renderer.render(value);
|
||||
String renderedValue;
|
||||
if (context.getTraceMode() == TraceMode.PRETTY) {
|
||||
renderedValue = multiLineRenderer.render(value);
|
||||
} else {
|
||||
renderedValue = singleLineRenderer.render(value);
|
||||
}
|
||||
var message =
|
||||
(sourceSection.isAvailable() ? sourceSection.getCharacters() : "<value")
|
||||
+ " = "
|
||||
|
||||
@@ -50,7 +50,8 @@ public record PklEvaluatorSettings(
|
||||
@Nullable Path rootDir,
|
||||
@Nullable Http http,
|
||||
@Nullable Map<String, ExternalReader> externalModuleReaders,
|
||||
@Nullable Map<String, ExternalReader> externalResourceReaders) {
|
||||
@Nullable Map<String, ExternalReader> externalResourceReaders,
|
||||
@Nullable TraceMode traceMode) {
|
||||
|
||||
/** Initializes a {@link PklEvaluatorSettings} from a raw object representation. */
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -106,6 +107,7 @@ public record PklEvaluatorSettings(
|
||||
Entry::getKey, entry -> ExternalReader.parse(entry.getValue())));
|
||||
|
||||
var color = (String) pSettings.get("color");
|
||||
var traceMode = (String) pSettings.get("traceMode");
|
||||
|
||||
return new PklEvaluatorSettings(
|
||||
(Map<String, String>) pSettings.get("externalProperties"),
|
||||
@@ -120,7 +122,8 @@ public record PklEvaluatorSettings(
|
||||
rootDir,
|
||||
Http.parse((Value) pSettings.get("http")),
|
||||
externalModuleReaders,
|
||||
externalResourceReaders);
|
||||
externalResourceReaders,
|
||||
traceMode == null ? null : TraceMode.valueOf(traceMode.toUpperCase()));
|
||||
}
|
||||
|
||||
public record Http(@Nullable Proxy proxy, @Nullable Map<URI, URI> rewrites) {
|
||||
@@ -231,7 +234,8 @@ public record PklEvaluatorSettings(
|
||||
&& Objects.equals(moduleCacheDir, that.moduleCacheDir)
|
||||
&& Objects.equals(timeout, that.timeout)
|
||||
&& Objects.equals(rootDir, that.rootDir)
|
||||
&& Objects.equals(http, that.http);
|
||||
&& Objects.equals(http, that.http)
|
||||
&& Objects.equals(traceMode, that.traceMode);
|
||||
}
|
||||
|
||||
private int hashPatterns(@Nullable List<Pattern> patterns) {
|
||||
@@ -249,7 +253,15 @@ public record PklEvaluatorSettings(
|
||||
public int hashCode() {
|
||||
var result =
|
||||
Objects.hash(
|
||||
externalProperties, env, color, noCache, moduleCacheDir, timeout, rootDir, http);
|
||||
externalProperties,
|
||||
env,
|
||||
color,
|
||||
noCache,
|
||||
moduleCacheDir,
|
||||
timeout,
|
||||
rootDir,
|
||||
http,
|
||||
traceMode);
|
||||
result = 31 * result + hashPatterns(allowedModules);
|
||||
result = 31 * result + hashPatterns(allowedResources);
|
||||
return result;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright © 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.pkl.core.evaluatorSettings;
|
||||
|
||||
/** Dictates the rendering of calls to the trace() method within Pkl. */
|
||||
public enum TraceMode {
|
||||
/** All trace() calls will not be emitted to stderr. */
|
||||
HIDDEN,
|
||||
/** All structures passed to trace() will be emitted on a single line. */
|
||||
DEFAULT,
|
||||
/** All structures passed to trace() will be indented and emitted across multiple lines. */
|
||||
PRETTY
|
||||
}
|
||||
@@ -79,7 +79,8 @@ public abstract class AbstractMessagePackEncoder implements MessageEncoder {
|
||||
@Nullable Object valueC,
|
||||
@Nullable Object valueD,
|
||||
@Nullable Object valueE,
|
||||
@Nullable Object valueF)
|
||||
@Nullable Object valueF,
|
||||
@Nullable Object valueG)
|
||||
throws IOException {
|
||||
packer.packMapHeader(
|
||||
size
|
||||
@@ -97,7 +98,8 @@ public abstract class AbstractMessagePackEncoder implements MessageEncoder {
|
||||
+ (valueC != null ? 1 : 0)
|
||||
+ (valueD != null ? 1 : 0)
|
||||
+ (valueE != null ? 1 : 0)
|
||||
+ (valueF != null ? 1 : 0));
|
||||
+ (valueF != null ? 1 : 0)
|
||||
+ (valueG != null ? 1 : 0));
|
||||
}
|
||||
|
||||
protected void packKeyValue(String name, @Nullable Integer value) throws IOException {
|
||||
|
||||
@@ -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.
|
||||
@@ -43,6 +43,7 @@ import org.pkl.core.StackFrameTransformers;
|
||||
import org.pkl.core.Value;
|
||||
import org.pkl.core.Version;
|
||||
import org.pkl.core.evaluatorSettings.PklEvaluatorSettings;
|
||||
import org.pkl.core.evaluatorSettings.TraceMode;
|
||||
import org.pkl.core.module.ModuleKeyFactories;
|
||||
import org.pkl.core.packages.Checksums;
|
||||
import org.pkl.core.packages.Dependency.RemoteDependency;
|
||||
@@ -197,7 +198,8 @@ public final class Project {
|
||||
builder.getModuleKeyFactories(),
|
||||
builder.getModuleCacheDir(),
|
||||
builder.getProjectDependencies(),
|
||||
builder.getHttpClient());
|
||||
builder.getHttpClient(),
|
||||
builder.getTraceMode());
|
||||
var importGraph = analyzer.importGraph(moduleSource.getUri());
|
||||
var ret = ImportGraphUtils.findImportCycles(importGraph);
|
||||
// we only care about cycles in the same scheme as `moduleSource`
|
||||
@@ -511,7 +513,8 @@ public final class Project {
|
||||
@Nullable Path moduleCacheDir,
|
||||
@Nullable List<Path> modulePath,
|
||||
@Nullable Duration timeout,
|
||||
@Nullable Path rootDir) {
|
||||
@Nullable Path rootDir,
|
||||
@Nullable TraceMode traceMode) {
|
||||
this.delegate =
|
||||
new PklEvaluatorSettings(
|
||||
externalProperties,
|
||||
@@ -526,7 +529,8 @@ public final class Project {
|
||||
rootDir,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
null,
|
||||
traceMode);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
@@ -610,6 +614,8 @@ public final class Project {
|
||||
+ delegate.timeout()
|
||||
+ ", rootDir="
|
||||
+ delegate.rootDir()
|
||||
+ ", traceMode="
|
||||
+ delegate.traceMode()
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.pkl.core.ast.builder.AstBuilder;
|
||||
import org.pkl.core.ast.member.*;
|
||||
import org.pkl.core.ast.repl.ResolveClassMemberNode;
|
||||
import org.pkl.core.ast.type.TypeNode;
|
||||
import org.pkl.core.evaluatorSettings.TraceMode;
|
||||
import org.pkl.core.http.HttpClient;
|
||||
import org.pkl.core.module.*;
|
||||
import org.pkl.core.packages.PackageResolver;
|
||||
@@ -82,7 +83,8 @@ public class ReplServer implements AutoCloseable {
|
||||
@Nullable String outputFormat,
|
||||
Path workingDir,
|
||||
StackFrameTransformer frameTransformer,
|
||||
boolean color) {
|
||||
boolean color,
|
||||
@Nullable TraceMode traceMode) {
|
||||
|
||||
this.workingDir = workingDir;
|
||||
this.securityManager = securityManager;
|
||||
@@ -114,7 +116,8 @@ public class ReplServer implements AutoCloseable {
|
||||
moduleCacheDir,
|
||||
outputFormat,
|
||||
packageResolver,
|
||||
projectDependenciesManager));
|
||||
projectDependenciesManager,
|
||||
traceMode));
|
||||
});
|
||||
language = languageRef.get();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -49,6 +49,7 @@ public abstract class StdLibModule {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null));
|
||||
var language = VmLanguage.get(null);
|
||||
var moduleKey = ModuleKeys.standardLibrary(uri);
|
||||
|
||||
@@ -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.util.Map;
|
||||
import org.pkl.core.Logger;
|
||||
import org.pkl.core.SecurityManager;
|
||||
import org.pkl.core.StackFrameTransformer;
|
||||
import org.pkl.core.evaluatorSettings.TraceMode;
|
||||
import org.pkl.core.http.HttpClient;
|
||||
import org.pkl.core.module.ProjectDependenciesManager;
|
||||
import org.pkl.core.packages.PackageResolver;
|
||||
@@ -50,6 +51,7 @@ public final class VmContext {
|
||||
private final ModuleCache moduleCache;
|
||||
private final @Nullable PackageResolver packageResolver;
|
||||
private final @Nullable ProjectDependenciesManager projectDependenciesManager;
|
||||
private final TraceMode traceMode;
|
||||
|
||||
public Holder(
|
||||
StackFrameTransformer frameTransformer,
|
||||
@@ -63,7 +65,8 @@ public final class VmContext {
|
||||
@Nullable Path moduleCacheDir,
|
||||
@Nullable String outputFormat,
|
||||
@Nullable PackageResolver packageResolver,
|
||||
@Nullable ProjectDependenciesManager projectDependenciesManager) {
|
||||
@Nullable ProjectDependenciesManager projectDependenciesManager,
|
||||
@Nullable TraceMode traceMode) {
|
||||
|
||||
this.frameTransformer = frameTransformer;
|
||||
this.securityManager = securityManager;
|
||||
@@ -84,6 +87,7 @@ public final class VmContext {
|
||||
moduleCache = new ModuleCache();
|
||||
this.packageResolver = packageResolver;
|
||||
this.projectDependenciesManager = projectDependenciesManager;
|
||||
this.traceMode = traceMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,4 +147,8 @@ public final class VmContext {
|
||||
public @Nullable ProjectDependenciesManager getProjectDependenciesManager() {
|
||||
return holder.projectDependenciesManager;
|
||||
}
|
||||
|
||||
public @Nullable TraceMode getTraceMode() {
|
||||
return holder.traceMode;
|
||||
}
|
||||
}
|
||||
|
||||
5
pkl-core/src/test/files/LanguageSnippetTests/input/projects/defaultTraceMode/PklProject
vendored
Normal file
5
pkl-core/src/test/files/LanguageSnippetTests/input/projects/defaultTraceMode/PklProject
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
amends "pkl:Project"
|
||||
|
||||
evaluatorSettings {
|
||||
traceMode = "default"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
amends ".../snippetTest.pkl"
|
||||
|
||||
examples {
|
||||
["traceMode = 'default' results in single-line trace() values"] {
|
||||
trace(new {
|
||||
["Parrot"] {
|
||||
name = "Parrot"
|
||||
age = 1234
|
||||
bucketSettings = new {
|
||||
kicked = true
|
||||
["fjordConfig"] = new {
|
||||
isPining = true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
18
pkl-core/src/test/files/LanguageSnippetTests/input/projects/evaluatorSettings/nullTraceMode.pkl
vendored
Normal file
18
pkl-core/src/test/files/LanguageSnippetTests/input/projects/evaluatorSettings/nullTraceMode.pkl
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
amends ".../snippetTest.pkl"
|
||||
|
||||
examples {
|
||||
["traceMode = null results in single-line trace() values"] {
|
||||
trace(new {
|
||||
["Parrot"] {
|
||||
name = "Parrot"
|
||||
age = 1234
|
||||
bucketSettings = new {
|
||||
kicked = true
|
||||
["fjordConfig"] = new {
|
||||
isPining = true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
5
pkl-core/src/test/files/LanguageSnippetTests/input/projects/hiddenTraceMode/PklProject
vendored
Normal file
5
pkl-core/src/test/files/LanguageSnippetTests/input/projects/hiddenTraceMode/PklProject
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
amends "pkl:Project"
|
||||
|
||||
evaluatorSettings {
|
||||
traceMode = "hidden"
|
||||
}
|
||||
18
pkl-core/src/test/files/LanguageSnippetTests/input/projects/hiddenTraceMode/hiddenTraceMode.pkl
vendored
Normal file
18
pkl-core/src/test/files/LanguageSnippetTests/input/projects/hiddenTraceMode/hiddenTraceMode.pkl
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
5
pkl-core/src/test/files/LanguageSnippetTests/input/projects/prettyTraceMode/PklProject
vendored
Normal file
5
pkl-core/src/test/files/LanguageSnippetTests/input/projects/prettyTraceMode/PklProject
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
amends "pkl:Project"
|
||||
|
||||
evaluatorSettings {
|
||||
traceMode = "pretty"
|
||||
}
|
||||
18
pkl-core/src/test/files/LanguageSnippetTests/input/projects/prettyTraceMode/prettyTraceMode.pkl
vendored
Normal file
18
pkl-core/src/test/files/LanguageSnippetTests/input/projects/prettyTraceMode/prettyTraceMode.pkl
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
amends ".../snippetTest.pkl"
|
||||
|
||||
examples {
|
||||
["traceMode = 'pretty' results in indented, multi-line output"] {
|
||||
trace(new {
|
||||
["Parrot"] {
|
||||
name = "Parrot"
|
||||
age = 1234
|
||||
bucketSettings = new {
|
||||
kicked = true
|
||||
["fjordConfig"] = new {
|
||||
isPining = true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
examples {
|
||||
["traceMode = 'default' results in single-line trace() values"] {
|
||||
new {
|
||||
["Parrot"] {
|
||||
name = "Parrot"
|
||||
age = 1234
|
||||
bucketSettings {
|
||||
kicked = true
|
||||
["fjordConfig"] {
|
||||
isPining = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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/defaultTraceMode/defaultTraceMode.pkl)
|
||||
28
pkl-core/src/test/files/LanguageSnippetTests/output/projects/evaluatorSettings/nullTraceMode.err
vendored
Normal file
28
pkl-core/src/test/files/LanguageSnippetTests/output/projects/evaluatorSettings/nullTraceMode.err
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
examples {
|
||||
["traceMode = null results in single-line trace() values"] {
|
||||
new {
|
||||
["Parrot"] {
|
||||
name = "Parrot"
|
||||
age = 1234
|
||||
bucketSettings {
|
||||
kicked = true
|
||||
["fjordConfig"] {
|
||||
isPining = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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/evaluatorSettings/nullTraceMode.pkl)
|
||||
16
pkl-core/src/test/files/LanguageSnippetTests/output/projects/hiddenTraceMode/hiddenTraceMode.pcf
vendored
Normal file
16
pkl-core/src/test/files/LanguageSnippetTests/output/projects/hiddenTraceMode/hiddenTraceMode.pcf
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
examples {
|
||||
["traceMode = 'hidden' results in no trace output"] {
|
||||
new {
|
||||
["Parrot"] {
|
||||
name = "Parrot"
|
||||
age = 1234
|
||||
bucketSettings {
|
||||
kicked = true
|
||||
["fjordConfig"] {
|
||||
isPining = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
39
pkl-core/src/test/files/LanguageSnippetTests/output/projects/prettyTraceMode/prettyTraceMode.err
vendored
Normal file
39
pkl-core/src/test/files/LanguageSnippetTests/output/projects/prettyTraceMode/prettyTraceMode.err
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
examples {
|
||||
["traceMode = 'pretty' results in indented, multi-line output"] {
|
||||
new {
|
||||
["Parrot"] {
|
||||
name = "Parrot"
|
||||
age = 1234
|
||||
bucketSettings {
|
||||
kicked = true
|
||||
["fjordConfig"] {
|
||||
isPining = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
@@ -37,6 +37,7 @@ class AnalyzerTest {
|
||||
null,
|
||||
null,
|
||||
HttpClient.dummyClient(),
|
||||
null,
|
||||
)
|
||||
|
||||
@Test
|
||||
@@ -115,6 +116,7 @@ class AnalyzerTest {
|
||||
tempDir.resolve("packages"),
|
||||
null,
|
||||
HttpClient.dummyClient(),
|
||||
null,
|
||||
)
|
||||
PackageServer.populateCacheDir(tempDir.resolve("packages"))
|
||||
val file1 =
|
||||
@@ -190,6 +192,7 @@ class AnalyzerTest {
|
||||
tempDir.resolve("packages"),
|
||||
project.dependencies,
|
||||
HttpClient.dummyClient(),
|
||||
null,
|
||||
)
|
||||
val file1 =
|
||||
tempDir
|
||||
@@ -302,6 +305,7 @@ class AnalyzerTest {
|
||||
tempDir.resolve("packages"),
|
||||
project.dependencies,
|
||||
HttpClient.dummyClient(),
|
||||
null,
|
||||
)
|
||||
val result = analyzer.importGraph(mainPkl.toUri())
|
||||
val birdUri = URI("projectpackage://localhost:0/birds@1.0.0#/bird.pkl")
|
||||
|
||||
@@ -45,6 +45,7 @@ class ReplServerTest {
|
||||
"/".toPath(),
|
||||
StackFrameTransformers.defaultTransformer,
|
||||
false,
|
||||
null,
|
||||
)
|
||||
|
||||
@Test
|
||||
|
||||
@@ -74,6 +74,7 @@ class ProjectTest {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
)
|
||||
val expectedAnnotations =
|
||||
listOf(
|
||||
|
||||
Reference in New Issue
Block a user