Skip to content

Commit

Permalink
cmd/cue: add integration test for CUE_DEBUG=sortfields
Browse files Browse the repository at this point in the history
It doesn't seem to work for evalv2; the following commit fixes that.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I64f39ee87a98d7f1fcda613001136291eb3e3c99
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1204654
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Matthew Sackman <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
  • Loading branch information
mvdan committed Nov 26, 2024
1 parent 00ca1c9 commit e514fb7
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions cmd/cue/cmd/testdata/script/sortfields.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Test that CUE_DEBUG=sortfields is wired up correctly.

# First, ensure that this debugging option is off by default.
exec cue export input.cue
cmp stdout export-unsorted.stdout

# Turn it on and ensure it works as expected for various commands and encodings.
# TODO: sortfields does not seem to work at all for evalv2.
env CUE_DEBUG=sortfields

exec cue export input.cue
cmp stdout export.stdout

exec cue export --out yaml input.cue
cmp stdout export-yaml.stdout

exec cue def input.cue
cmp stdout def.stdout

exec cue eval input.cue
cmp stdout eval.stdout

# Just to double check, ensure it also works for evalv3.
env CUE_EXPERIMENT=evalv3
exec cue export input.cue
cmp stdout export-evalv3.stdout

-- input.cue --
c: true
b: {
x: true
z: true
}
a: true
b: y: true
-- export-unsorted.stdout --
{
"c": true,
"b": {
"x": true,
"y": true,
"z": true
},
"a": true
}
-- export.stdout --
{
"c": true,
"b": {
"x": true,
"y": true,
"z": true
},
"a": true
}
-- export-evalv3.stdout --
{
"a": true,
"b": {
"x": true,
"y": true,
"z": true
},
"c": true
}
-- export-yaml.stdout --
c: true
b:
x: true
"y": true
z: true
a: true
-- def.stdout --
c: true
b: {
x: true
y: true
z: true
}
a: true
-- eval.stdout --
c: true
b: {
x: true
y: true
z: true
}
a: true

0 comments on commit e514fb7

Please sign in to comment.