this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd/cue: add regression test for 'cue cmd' with many packages

Thanks to Paul Jolly for writing the testscript in a comment on #1325.
It is added here with some minor tweaks: adding more comments,
and reflecting the current behavior with the last command failing.

Without such a test, it's hard to notice when we might break users
who rely on the existing behavior, intentionally or not.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I82d0229d085e8d63fc3e170e2c92f66434159117
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193717
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Paul Jolly <paul@myitcv.io>

+98
+98
cmd/cue/cmd/testdata/script/cmd_many.txtar
··· 1 + # Test cue cmd's behavior when given multiple packages. 2 + # Note that we're not sure if this is the behavior we want long term, 3 + # but it is the behavior we have had for some time, and some users 4 + # are currently reliant on it. See https://cuelang.org/issue/1325. 5 + 6 + # Export with itemsList_tool.cue in place. 7 + exec cue export ./... 8 + cmp stdout stdout.export-pre.golden 9 + 10 + # Verify that cue cmd ls ./... works. 11 + # Note that a single ls command is run with a single package value 12 + # reuslting from the unification of all packages in ./... 13 + exec cue cmd ls ./... 14 + cmp stdout stdout.ls-pre.golden 15 + 16 + # Now rename itemsList_tool.cue to itemsList.cue. 17 + mv itemsList_tool.cue itemsList.cue 18 + 19 + # Export with itemsList.cue in place. 20 + exec cue export ./... 21 + cmp stdout stdout.export-post.golden 22 + 23 + # Attempt to ls in this state, which fails, as each of the CUE packages 24 + # hold an items list with different lengths. 25 + ! exec cue cmd ls ./... 26 + stderr 'itemsList: incompatible list lengths \(0 and 1\)' 27 + 28 + -- cue.mod/module.cue -- 29 + module: "mod.com" 30 + -- x.cue -- 31 + package x 32 + 33 + items: {} 34 + -- ls_tool.cue -- 35 + package x 36 + 37 + import ( 38 + "tool/cli" 39 + "strings" 40 + ) 41 + 42 + command: ls: cli.Print & { 43 + text: "ls: " + strings.Join(itemsList, " ") + "\n" 44 + } 45 + -- itemsList_tool.cue -- 46 + package x 47 + 48 + itemsList: [for _, v in items {v}] 49 + -- a/x.cue -- 50 + package x 51 + 52 + items: { 53 + a: "a" 54 + } 55 + -- b/x.cue -- 56 + package x 57 + 58 + items: { 59 + b: "b" 60 + } 61 + -- stdout.export-pre.golden -- 62 + { 63 + "items": {} 64 + } 65 + { 66 + "items": { 67 + "a": "a" 68 + } 69 + } 70 + { 71 + "items": { 72 + "b": "b" 73 + } 74 + } 75 + -- stdout.ls-pre.golden -- 76 + ls: a b 77 + 78 + -- stdout.export-post.golden -- 79 + { 80 + "itemsList": [], 81 + "items": {} 82 + } 83 + { 84 + "itemsList": [ 85 + "a" 86 + ], 87 + "items": { 88 + "a": "a" 89 + } 90 + } 91 + { 92 + "itemsList": [ 93 + "b" 94 + ], 95 + "items": { 96 + "b": "b" 97 + } 98 + }