Skip to content

Commit a6abf3b

Browse files
committed
internal/core/adt: normalize how the tests configure the runtime
That is, set all options on the runtime when it is created, rather than directly modifying fields on the internal OpContext. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I974fbe00c356e542f14e300415e4185a8d5aa03a Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1218150 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent 7a237eb commit a6abf3b

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

internal/core/adt/eval_test.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,43 +50,50 @@ func TestEvalV2(t *testing.T) {
5050
}
5151

5252
cuedebug.Init()
53-
flags := cuedebug.Flags
53+
dbg := cuedebug.Flags
54+
cueexperiment.Init()
55+
exp := cueexperiment.Flags
5456

5557
if *todo {
5658
test.ToDo = nil
5759
}
5860

5961
test.Run(t, func(tc *cuetxtar.Test) {
60-
runEvalTest(tc, internal.EvalV2, flags)
62+
runEvalTest(tc, internal.EvalV2, dbg, exp)
6163
})
6264
}
6365

6466
func TestEvalV3(t *testing.T) {
6567
adt.DebugDeps = true // check unmatched dependencies.
6668

67-
cuedebug.Init()
68-
flags := cuedebug.Flags
69-
7069
test := cuetxtar.TxTarTest{
7170
Root: "../../../cue/testdata",
7271
Name: "evalalpha",
7372
Fallback: "eval", // Allow eval golden files to pass these tests.
7473
}
7574

75+
cuedebug.Init()
76+
dbg := cuedebug.Flags
77+
cueexperiment.Init()
78+
exp := cueexperiment.Flags
79+
7680
if *todo {
7781
test.ToDo = nil
7882
}
7983

8084
var errorCount int
8185
test.Run(t, func(t *cuetxtar.Test) {
82-
errorCount += runEvalTest(t, internal.EvalV3, flags)
86+
errorCount += runEvalTest(t, internal.EvalV3, dbg, exp)
8387
})
8488
t.Logf("nodeErrors: %d", errorCount)
8589
}
8690

87-
func runEvalTest(t *cuetxtar.Test, version internal.EvaluatorVersion, flags cuedebug.Config) (errorCount int) {
91+
func runEvalTest(t *cuetxtar.Test, version internal.EvaluatorVersion, dbg cuedebug.Config, exp cueexperiment.Config) (errorCount int) {
92+
exp.KeepValidators = !t.HasTag("simplifyValidators")
93+
8894
a := t.Instance()
89-
r := runtime.NewWithSettings(version, flags)
95+
r := runtime.NewWithSettings(version, dbg)
96+
r.SetGlobalExperiments(&exp)
9097

9198
v, err := r.Build(nil, a)
9299
if err != nil {
@@ -96,9 +103,6 @@ func runEvalTest(t *cuetxtar.Test, version internal.EvaluatorVersion, flags cued
96103

97104
e := eval.New(r)
98105
ctx := e.NewContext(v)
99-
ctx.Version = version
100-
ctx.Config = flags
101-
ctx.SimplifyValidators = t.HasTag("simplifyValidators")
102106
v.Finalize(ctx)
103107

104108
switch counts := ctx.Stats(); {

0 commit comments

Comments
 (0)