-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
1 parent
4eecacd
commit 8079151
Showing
11 changed files
with
195 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# TODO: make this optional | ||
-- in.cue -- | ||
foo: [string]: a: *1 | int | ||
foo: b: a: 1 | ||
-- out/trim -- | ||
== in.cue | ||
foo: [string]: a: *1 | int | ||
foo: b: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-- in.cue -- | ||
foo: multipath: { | ||
t: [string]: { x: 5 } | ||
|
||
// Don't remove u! | ||
t: u: { x: 5 } | ||
} | ||
|
||
group: { | ||
for k, v in foo { | ||
comp: "\(k)": v | ||
} | ||
} | ||
-- out/trim -- | ||
== in.cue | ||
foo: multipath: { | ||
t: [string]: {x: 5} | ||
|
||
// Don't remove u! | ||
t: u: {} | ||
} | ||
|
||
group: { | ||
for k, v in foo { | ||
comp: "\(k)": v | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- in.cue -- | ||
{[_]: x: "hello"} | ||
a: x: "hello" | ||
-- out/trim -- | ||
== in.cue | ||
{[_]: x: "hello"} | ||
a: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- in.cue -- | ||
foo: c: true | ||
foo: #M | ||
#M: c?: bool | ||
-- out/trim -- | ||
== in.cue | ||
foo: c: true | ||
foo: #M | ||
#M: c?: bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- in.cue -- | ||
service: [string]: { | ||
ports: [{a: 1}, {a: 1}, ...{ extra: 3 }] | ||
} | ||
service: a: { | ||
ports: [{a: 1}, {a: 1, extra: 3}, {}, { extra: 3 }] | ||
} | ||
-- out/trim -- | ||
== in.cue | ||
service: [string]: { | ||
ports: [{a: 1}, {a: 1}, ...{extra: 3}] | ||
} | ||
service: a: { | ||
ports: [{}, {extra: 3}, {}, {}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- in.cue -- | ||
service: [string]: { | ||
ports: [{a: 1}, {a: 1}, ...{ extra: 3 }] | ||
} | ||
service: a: { | ||
ports: [{a: 1}, {a: 1,}] | ||
} | ||
-- out/trim -- | ||
== in.cue | ||
service: [string]: { | ||
ports: [{a: 1}, {a: 1}, ...{extra: 3}] | ||
} | ||
service: a: {} |
23 changes: 23 additions & 0 deletions
23
tools/trim/testdata/optional_does_not_remove_required.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- in.cue -- | ||
a: ["aFoo"]: 3 | ||
a: aFoo: _ | ||
|
||
a: { | ||
{["aFoo"]: 3} | ||
aFoo: _ | ||
} | ||
|
||
["aFoo"]: 3 | ||
aFoo: _ | ||
-- out/trim -- | ||
== in.cue | ||
a: ["aFoo"]: 3 | ||
a: aFoo: _ | ||
|
||
a: { | ||
{["aFoo"]: 3} | ||
aFoo: _ | ||
} | ||
|
||
["aFoo"]: 3 | ||
aFoo: _ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-- in.cue -- | ||
foo: [string]: { | ||
t: [string]: { | ||
x: >=0 & <=5 | ||
} | ||
} | ||
|
||
foo: multipath: { | ||
t: [string]: { | ||
// Combined with the other constraints, we know the value must be 5 and | ||
// thus the entry below can be eliminated. | ||
x: >=5 & <=8 & int | ||
} | ||
|
||
t: u: { x: 5 } | ||
} | ||
|
||
group: { | ||
for k, v in foo { | ||
comp: "\(k)": v | ||
} | ||
} | ||
-- out/trim -- | ||
== in.cue | ||
foo: [string]: { | ||
t: [string]: { | ||
x: >=0 & <=5 | ||
} | ||
} | ||
|
||
foo: multipath: { | ||
t: [string]: { | ||
// Combined with the other constraints, we know the value must be 5 and | ||
// thus the entry below can be eliminated. | ||
x: >=5 & <=8 & int | ||
} | ||
|
||
t: u: {} | ||
} | ||
|
||
group: { | ||
for k, v in foo { | ||
comp: "\(k)": v | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- in.cue -- | ||
foo: [string]: { | ||
a: string | ||
b: "--\(a)--" | ||
} | ||
foo: entry: { | ||
a: "insert" | ||
b: "--insert--" | ||
} | ||
-- out/trim -- | ||
== in.cue | ||
foo: [string]: { | ||
a: string | ||
b: "--\(a)--" | ||
} | ||
foo: entry: { | ||
a: "insert" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- in.cue -- | ||
a: b: 3 | ||
for k, v in a { | ||
c: "\(k)": v | ||
} | ||
c: b: 3 | ||
|
||
z: { | ||
|
||
a: b: 3 | ||
for k, v in a { | ||
c: "\(k)": v | ||
} | ||
c: b: 3 | ||
} | ||
-- out/trim -- | ||
== in.cue | ||
a: b: 3 | ||
for k, v in a { | ||
c: "\(k)": v | ||
} | ||
|
||
z: { | ||
|
||
a: b: 3 | ||
for k, v in a { | ||
c: "\(k)": v | ||
} | ||
} |
Oops, something went wrong.