this repo has no description
0
fork

Configure Feed

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

cmd/cue: add testscript for #2648

Showing a simplified version of the original reproducer,
and then including two variants with aliases and lets,
because a naive solution would be to avoid wrapping some file values
in structs which would cause duplicate alias or let names.

We use a testscript rather than a test in internal/core/export/testdata
because these tests require multiple files to properly reproduce.

For #2648.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ie89cea7a4b8fe30dbc5fb9b1ddcef01ffbe863e2
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1233925
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Matthew Sackman <matthew@cue.works>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+109
+109
cmd/cue/cmd/testdata/script/issue2648.txtar
··· 1 + # Various edge cases for `cue def` where references across files 2 + # must still work in the self-contained result. 3 + # We also include cases where joining the file values without 4 + # lexical scopes can introduce duplicate names, such as aliases and lets. 5 + 6 + exec cue export . 7 + cmp stdout export.stdout 8 + 9 + exec cue def . 10 + cmp stdout def.stdout 11 + stdin stdout 12 + # TODO: this should succeed, and show output equivalent to the earlier export. 13 + ! exec cue export - 14 + cmp stderr stderr-bug.golden 15 + 16 + -- def.stdout -- 17 + package p 18 + 19 + let L = true 20 + let L_1 = false 21 + { 22 + crossfile_alias: "referenced from sibling file" 23 + A="non ident": true 24 + if A { 25 + alias1_used: true 26 + } 27 + } 28 + { 29 + A="another non ident": false 30 + crossfile_alias_ref: crossfile_alias 31 + alias2_mark_used: A 32 + } 33 + { 34 + crossfile_let: "referenced from sibling file" 35 + if L { 36 + let1_used: true 37 + } 38 + } 39 + { 40 + crossfile_simple: true 41 + if crossfile_simple { 42 + simple1_used: true 43 + } 44 + } 45 + crossfile_let_ref: crossfile_let 46 + crossfile_simple_ref: crossfile_simple 47 + let2_mark_used: L_1 48 + -- export.stdout -- 49 + { 50 + "another non ident": false, 51 + "crossfile_alias": "referenced from sibling file", 52 + "crossfile_alias_ref": "referenced from sibling file", 53 + "alias2_mark_used": false, 54 + "crossfile_let": "referenced from sibling file", 55 + "crossfile_let_ref": "referenced from sibling file", 56 + "crossfile_simple": true, 57 + "crossfile_simple_ref": true, 58 + "let1_used": true, 59 + "let2_mark_used": false, 60 + "non ident": true, 61 + "alias1_used": true, 62 + "simple1_used": true 63 + } 64 + -- stderr-bug.golden -- 65 + crossfile_alias_ref: reference "crossfile_alias" not found: 66 + -:14:25 67 + crossfile_let_ref: reference "crossfile_let" not found: 68 + -:29:23 69 + crossfile_simple_ref: reference "crossfile_simple" not found: 70 + -:30:23 71 + -- simple_1.cue -- 72 + package p 73 + 74 + crossfile_simple: true 75 + if crossfile_simple { 76 + simple1_used: true 77 + } 78 + -- simple_2.cue -- 79 + package p 80 + 81 + crossfile_simple_ref: crossfile_simple 82 + -- alias_1.cue -- 83 + package p 84 + 85 + crossfile_alias: "referenced from sibling file" 86 + A="non ident": true 87 + if A { 88 + alias1_used: true 89 + } 90 + -- alias_2.cue -- 91 + package p 92 + 93 + A="another non ident": false 94 + crossfile_alias_ref: crossfile_alias 95 + alias2_mark_used: A 96 + -- let_1.cue -- 97 + package p 98 + 99 + crossfile_let: "referenced from sibling file" 100 + let L = true 101 + if L { 102 + let1_used: true 103 + } 104 + -- let_2.cue -- 105 + package p 106 + 107 + crossfile_let_ref: crossfile_let 108 + let L = false 109 + let2_mark_used: L