Skip to content

Commit 8079151

Browse files
committed
tools/trim: convert inline tests to txtar
txtar is the preferred mechanism for tests that drive cue. Convert all existing trim tests to txtar. The txtar tests run as part of the existing TestTrimFiles target (renamed from TestData to be a little more descriptive). Remove TestX because the TxTarTest code supports DebugArchive which allows easy overriding for the purposes of experimentation. Signed-off-by: Matthew Sackman <[email protected]> Change-Id: I985f2e27b32fe01fb6b36b5e124cbb5c986c180e Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1197348 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 4eecacd commit 8079151

11 files changed

+195
-296
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# TODO: make this optional
2+
-- in.cue --
3+
foo: [string]: a: *1 | int
4+
foo: b: a: 1
5+
-- out/trim --
6+
== in.cue
7+
foo: [string]: a: *1 | int
8+
foo: b: {}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-- in.cue --
2+
foo: multipath: {
3+
t: [string]: { x: 5 }
4+
5+
// Don't remove u!
6+
t: u: { x: 5 }
7+
}
8+
9+
group: {
10+
for k, v in foo {
11+
comp: "\(k)": v
12+
}
13+
}
14+
-- out/trim --
15+
== in.cue
16+
foo: multipath: {
17+
t: [string]: {x: 5}
18+
19+
// Don't remove u!
20+
t: u: {}
21+
}
22+
23+
group: {
24+
for k, v in foo {
25+
comp: "\(k)": v
26+
}
27+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- in.cue --
2+
{[_]: x: "hello"}
3+
a: x: "hello"
4+
-- out/trim --
5+
== in.cue
6+
{[_]: x: "hello"}
7+
a: {}

tools/trim/testdata/issue303.txtar

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- in.cue --
2+
foo: c: true
3+
foo: #M
4+
#M: c?: bool
5+
-- out/trim --
6+
== in.cue
7+
foo: c: true
8+
foo: #M
9+
#M: c?: bool
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- in.cue --
2+
service: [string]: {
3+
ports: [{a: 1}, {a: 1}, ...{ extra: 3 }]
4+
}
5+
service: a: {
6+
ports: [{a: 1}, {a: 1, extra: 3}, {}, { extra: 3 }]
7+
}
8+
-- out/trim --
9+
== in.cue
10+
service: [string]: {
11+
ports: [{a: 1}, {a: 1}, ...{extra: 3}]
12+
}
13+
service: a: {
14+
ports: [{}, {extra: 3}, {}, {}]
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- in.cue --
2+
service: [string]: {
3+
ports: [{a: 1}, {a: 1}, ...{ extra: 3 }]
4+
}
5+
service: a: {
6+
ports: [{a: 1}, {a: 1,}]
7+
}
8+
-- out/trim --
9+
== in.cue
10+
service: [string]: {
11+
ports: [{a: 1}, {a: 1}, ...{extra: 3}]
12+
}
13+
service: a: {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- in.cue --
2+
a: ["aFoo"]: 3
3+
a: aFoo: _
4+
5+
a: {
6+
{["aFoo"]: 3}
7+
aFoo: _
8+
}
9+
10+
["aFoo"]: 3
11+
aFoo: _
12+
-- out/trim --
13+
== in.cue
14+
a: ["aFoo"]: 3
15+
a: aFoo: _
16+
17+
a: {
18+
{["aFoo"]: 3}
19+
aFoo: _
20+
}
21+
22+
["aFoo"]: 3
23+
aFoo: _
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
-- in.cue --
2+
foo: [string]: {
3+
t: [string]: {
4+
x: >=0 & <=5
5+
}
6+
}
7+
8+
foo: multipath: {
9+
t: [string]: {
10+
// Combined with the other constraints, we know the value must be 5 and
11+
// thus the entry below can be eliminated.
12+
x: >=5 & <=8 & int
13+
}
14+
15+
t: u: { x: 5 }
16+
}
17+
18+
group: {
19+
for k, v in foo {
20+
comp: "\(k)": v
21+
}
22+
}
23+
-- out/trim --
24+
== in.cue
25+
foo: [string]: {
26+
t: [string]: {
27+
x: >=0 & <=5
28+
}
29+
}
30+
31+
foo: multipath: {
32+
t: [string]: {
33+
// Combined with the other constraints, we know the value must be 5 and
34+
// thus the entry below can be eliminated.
35+
x: >=5 & <=8 & int
36+
}
37+
38+
t: u: {}
39+
}
40+
41+
group: {
42+
for k, v in foo {
43+
comp: "\(k)": v
44+
}
45+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- in.cue --
2+
foo: [string]: {
3+
a: string
4+
b: "--\(a)--"
5+
}
6+
foo: entry: {
7+
a: "insert"
8+
b: "--insert--"
9+
}
10+
-- out/trim --
11+
== in.cue
12+
foo: [string]: {
13+
a: string
14+
b: "--\(a)--"
15+
}
16+
foo: entry: {
17+
a: "insert"
18+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
-- in.cue --
2+
a: b: 3
3+
for k, v in a {
4+
c: "\(k)": v
5+
}
6+
c: b: 3
7+
8+
z: {
9+
10+
a: b: 3
11+
for k, v in a {
12+
c: "\(k)": v
13+
}
14+
c: b: 3
15+
}
16+
-- out/trim --
17+
== in.cue
18+
a: b: 3
19+
for k, v in a {
20+
c: "\(k)": v
21+
}
22+
23+
z: {
24+
25+
a: b: 3
26+
for k, v in a {
27+
c: "\(k)": v
28+
}
29+
}

0 commit comments

Comments
 (0)