From e514fb7bbbff359f5f4a746320f70f5e1a66e691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 26 Nov 2024 10:32:17 +0000 Subject: [PATCH] cmd/cue: add integration test for CUE_DEBUG=sortfields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It doesn't seem to work for evalv2; the following commit fixes that. Signed-off-by: Daniel Martí Change-Id: I64f39ee87a98d7f1fcda613001136291eb3e3c99 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1204654 TryBot-Result: CUEcueckoo Reviewed-by: Matthew Sackman Unity-Result: CUE porcuepine --- cmd/cue/cmd/testdata/script/sortfields.txtar | 88 ++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 cmd/cue/cmd/testdata/script/sortfields.txtar diff --git a/cmd/cue/cmd/testdata/script/sortfields.txtar b/cmd/cue/cmd/testdata/script/sortfields.txtar new file mode 100644 index 00000000000..e9f59273f41 --- /dev/null +++ b/cmd/cue/cmd/testdata/script/sortfields.txtar @@ -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