Add flag to turn power assertions on/off (#1419)

This commit is contained in:
Islon Scherer
2026-02-03 09:35:16 +01:00
committed by GitHub
parent 7b7b51c0ae
commit f0449c8330
29 changed files with 345 additions and 72 deletions

View File

@@ -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.
@@ -152,6 +152,9 @@ data class CliBaseOptions(
/** Defines options for the formatting of calls to the trace() method. */
val traceMode: TraceMode? = null,
/** Whether power assertions are enabled. */
val powerAssertionsEnabled: Boolean = false,
) {
companion object {

View File

@@ -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.
@@ -102,6 +102,7 @@ abstract class CliCommand(protected val cliOptions: CliBaseOptions) {
cliOptions.timeout,
stackFrameTransformer,
envVars,
cliOptions.powerAssertionsEnabled,
)
}
@@ -308,5 +309,6 @@ abstract class CliCommand(protected val cliOptions: CliBaseOptions) {
.setTimeout(cliOptions.timeout)
.setModuleCacheDir(moduleCacheDir)
.setTraceMode(traceMode)
.setPowerAssertionsEnabled(cliOptions.powerAssertionsEnabled)
}
}

View File

@@ -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.
@@ -316,6 +316,7 @@ class BaseOptions : OptionGroup() {
modules: List<URI>,
projectOptions: ProjectOptions? = null,
testMode: Boolean = false,
powerAssertionsEnabled: Boolean = false,
): CliBaseOptions {
return CliBaseOptions(
sourceModules = modules,
@@ -343,6 +344,7 @@ class BaseOptions : OptionGroup() {
externalModuleReaders = externalModuleReaders,
externalResourceReaders = externalResourceReaders,
traceMode = traceMode,
powerAssertionsEnabled = powerAssertionsEnabled,
)
}
}