Skip to content

Commit

Permalink
cmd/cue: add a regression test for an export -e bug fixed by evalv3
Browse files Browse the repository at this point in the history
The test case added below worked on CUE v0.5, was broken by v0.6,
and luckily is fixed by the new evaluator. Add a regression test
to ensure that it keeps working.

Unlike other evaluator regression tests, this one concerns the use
of the --expression flag, so we use a testscript.

Closes #2542.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I94d45fc89251ac390c4edecc9015147f5a7f78e5
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206351
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
mvdan committed Dec 27, 2024
1 parent b0c6204 commit 2589f7f
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions cmd/cue/cmd/testdata/script/export_expr.txtar
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
cd simple
exec cue export data.cue -e a+c -e d.e.f --out yaml
cmp stdout expect-stdout
-- expect-stdout --
cd ..

# Issue 2542 was a regression introduced in CUE v0.6 which was resolved by evalv3.
env CUE_EXPERIMENT=evalv3
cd issue2542
exec cue export -e 'obj2.name' input.cue
cmp stdout stdout.golden
cd ..

-- simple/expect-stdout --
4
---
jam
-- data.cue --
-- simple/data.cue --
a: 1
c: 3
d: e: f: "jam"
-- issue2542/input.cue --
obj: this={
(#makeName & {enable: this._enable}).out
}

obj: _enable: true

obj2: obj

#makeName: {
enable: bool
if enable {
out: name: "enabled"
}
if !enable {
out: name: "disabled"
}
}
-- issue2542/stdout.golden --
"enabled"

0 comments on commit 2589f7f

Please sign in to comment.