Skip to content

Commit

Permalink
internal/cuedebug: usurp some evaluator debug flags
Browse files Browse the repository at this point in the history
This required moving setting the default value only when
there actually is a default value to avoid a crash for
non-boolean values.

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I70b8826a838ae0263deeadffce71ba706d39dced
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193620
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
  • Loading branch information
mpvl committed Apr 23, 2024
1 parent 9c5c3c0 commit 4280d65
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
17 changes: 2 additions & 15 deletions internal/core/adt/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,9 @@ import (
"cuelang.org/go/cue/stats"
"cuelang.org/go/cue/token"
"cuelang.org/go/internal"
"cuelang.org/go/internal/cuedebug"
)

type DebugFlags struct {
// Strict sets whether extra aggressive checking should be done.
// This should typically default to true for pre-releases and default to
// false otherwise.
Strict bool

// LogEval sets the log level for the evaluator.
// There are currently only two levels:
//
// 0: no logging
// 1: logging
LogEval int
}

// DebugSort specifies that arcs be sorted consistently between implementations.
//
// 0: default
Expand Down Expand Up @@ -218,7 +205,7 @@ type OpContext struct {
Runtime
Format func(Node) string

DebugFlags
cuedebug.Config
Version internal.EvaluatorVersion // Copied from Runtime

taskContext
Expand Down
12 changes: 12 additions & 0 deletions internal/cuedebug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ var Flags Config

type Config struct {
HTTP bool

// Strict sets whether extra aggressive checking should be done.
// This should typically default to true for pre-releases and default to
// false otherwise.
Strict bool

// LogEval sets the log level for the evaluator.
// There are currently only two levels:
//
// 0: no logging
// 1: logging
LogEval int
}

// Init initializes Flags. Note: this isn't named "init" because we
Expand Down
2 changes: 1 addition & 1 deletion internal/envflag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func Init[T any](flags *T, envVar string) error {
return fmt.Errorf("invalid default bool value for %s: %v", field.Name, err)
}
defaultValue = v
fv.Field(i).SetBool(defaultValue)
}
fv.Field(i).SetBool(defaultValue)
indexByName[strings.ToLower(field.Name)] = i
}

Expand Down

0 comments on commit 4280d65

Please sign in to comment.