Skip to content

Commit

Permalink
cue/load: add test case for issue 3306
Browse files Browse the repository at this point in the history
This adds a test case for using `cue/load.Config.PkgName` as `*`,
showing extra files and instances that should not be present.

This behavior will be fixed in a subsequent CL.

For #3306

Signed-off-by: Roger Peppe <[email protected]>
Change-Id: Ibf19e020ecdfa58e6841d517f5fcf0282615504a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198685
Reviewed-by: Daniel Martí <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
rogpeppe committed Jul 31, 2024
1 parent 88306e2 commit f472fd2
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 2 deletions.
101 changes: 99 additions & 2 deletions cue/load/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,105 @@ path: ""
module: ""
root: ""
dir: ""
display:""`},
}
display:""`}, {
// This test checks that files in parent directories
// do not result in irrelevant instances appearing
// in the result of Instances.
name: "Issue3306",
cfg: &Config{
Dir: testdataDir,
Package: "*",
},
args: []string{"./issue3306/..."},
want: `path: mod.test/test/issue3306@v0:_
module: mod.test/test@v0
root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod/issue3306
display:./issue3306
files:
$CWD/testdata/testmod/anon.cue
path: mod.test/test/issue3306@v0:test
module: mod.test/test@v0
root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod/issue3306
display:./issue3306
files:
$CWD/testdata/testmod/test.cue
path: mod.test/test/issue3306@v0:x
module: mod.test/test@v0
root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod/issue3306
display:./issue3306
files:
$CWD/testdata/testmod/issue3306/x.cue
path: mod.test/test/issue3306/a@v0:_
module: mod.test/test@v0
root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod/issue3306/a
display:./issue3306/a
files:
$CWD/testdata/testmod/anon.cue
path: mod.test/test/issue3306/a@v0:a
module: mod.test/test@v0
root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod/issue3306/a
display:./issue3306/a
files:
$CWD/testdata/testmod/issue3306/a/a.cue
path: mod.test/test/issue3306/a@v0:b
module: mod.test/test@v0
root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod/issue3306/a
display:./issue3306/a
files:
$CWD/testdata/testmod/issue3306/a/b.cue
path: mod.test/test/issue3306/a@v0:test
module: mod.test/test@v0
root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod/issue3306/a
display:./issue3306/a
files:
$CWD/testdata/testmod/test.cue
path: mod.test/test/issue3306/a@v0:x
module: mod.test/test@v0
root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod/issue3306/a
display:./issue3306/a
files:
$CWD/testdata/testmod/issue3306/x.cue
$CWD/testdata/testmod/issue3306/a/x.cue
path: mod.test/test/issue3306/x@v0:_
module: mod.test/test@v0
root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod/issue3306/x
display:./issue3306/x
files:
$CWD/testdata/testmod/anon.cue
path: mod.test/test/issue3306/x@v0:test
module: mod.test/test@v0
root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod/issue3306/x
display:./issue3306/x
files:
$CWD/testdata/testmod/test.cue
path: mod.test/test/issue3306/x@v0:x
module: mod.test/test@v0
root: $CWD/testdata/testmod
dir: $CWD/testdata/testmod/issue3306/x
display:./issue3306/x
files:
$CWD/testdata/testmod/issue3306/x.cue
$CWD/testdata/testmod/issue3306/x/x.cue`}}
tdtest.Run(t, testCases, func(t *tdtest.T, tc *loadTest) {
pkgs := Instances(tc.args, tc.cfg)

Expand Down
3 changes: 3 additions & 0 deletions cue/load/testdata/testmod/issue3306/a/a.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package a

a: 4
3 changes: 3 additions & 0 deletions cue/load/testdata/testmod/issue3306/a/b.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package b

b: 3
1 change: 1 addition & 0 deletions cue/load/testdata/testmod/issue3306/a/x.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package x
3 changes: 3 additions & 0 deletions cue/load/testdata/testmod/issue3306/x.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package x

x: 5
1 change: 1 addition & 0 deletions cue/load/testdata/testmod/issue3306/x/x.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package x

0 comments on commit f472fd2

Please sign in to comment.