Skip to content

Commit 1a40fd4

Browse files
committed
internal/core/adt: obey internal/core/cuedebug defaults in TestEval
TestEval and TestEvalAlpha were hard-coding cuedebug.Config values, meaning that they didn't stay in sync with the defaults set by the cuedebug package via struct field tags. As such, until very recently, cmd/cue and Go API users of evalv3 were using openinline=1 as a default via cuedebug, but TestEvalAlpha was ignoring that default and running all tests with openinline=0. Follow the defaults, and allow overriding it if #openInline is present at the top of the txtar file. We only override the value if such a line exists, as otherwise we always replace the default value. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Ia004c216cbea5f0124d61abd76d9f893e98d2e99 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211946 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 32b845b commit 1a40fd4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

internal/core/adt/eval_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ func TestEval(t *testing.T) {
5353
ToDo: needFix,
5454
}
5555

56+
cuedebug.Init()
57+
flags := cuedebug.Flags
58+
5659
if *todo {
5760
test.ToDo = nil
5861
}
5962

6063
test.Run(t, func(tc *cuetxtar.Test) {
61-
runEvalTest(tc, internal.DefaultVersion, cuedebug.Config{})
64+
runEvalTest(tc, internal.DefaultVersion, flags)
6265
})
6366
}
6467

@@ -80,9 +83,8 @@ func TestEvalAlpha(t *testing.T) {
8083
//
8184
adt.DebugDeps = true // check unmatched dependencies.
8285

83-
flags := cuedebug.Config{
84-
Sharing: true,
85-
}
86+
cuedebug.Init()
87+
flags := cuedebug.Flags
8688

8789
var todoAlpha = map[string]string{}
8890

@@ -137,7 +139,10 @@ func skipFiles(a ...*ast.File) (reason string) {
137139
}
138140

139141
func runEvalTest(t *cuetxtar.Test, version internal.EvaluatorVersion, flags cuedebug.Config) (errorCount int) {
140-
flags.OpenInline = t.Bool("openInline")
142+
// If #openInline is set, override the default as set by the cuedebug package.
143+
if s, ok := t.Value("openInline"); ok {
144+
flags.OpenInline = s == "true"
145+
}
141146

142147
a := t.Instance()
143148
r := runtime.NewWithSettings(version, flags)

0 commit comments

Comments
 (0)