Skip to content

Commit 4111b3e

Browse files
committed
cue/load: add tests for issue 3213
Issue #3213 exposed a shortcoming in the modules logic when there is a Package field explicitly specified in the cue/load.Config struct. This CL adds some tests to expose existing behavior in this respect before a subsequent CL will apply a fix. For #3213. Signed-off-by: Roger Peppe <[email protected]> Change-Id: If101f7b6729acdc87a9ae62ebd932044fb276e51 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196177 Reviewed-by: Daniel Martí <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 63d1318 commit 4111b3e

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

cue/load/loader_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,46 @@ path: ""
426426
module: mod.test/wrong
427427
root: ""
428428
dir: ""
429+
display:""`}, {
430+
name: "ExplicitPackageWithUnqualifiedImportPath#1",
431+
cfg: &Config{
432+
Dir: filepath.Join(testdataDir, "multi"),
433+
Package: "main",
434+
},
435+
args: []string{"."},
436+
want: `err: found packages "main" (file.cue) and "test_package" (file_appengine.cue) in "multi"
437+
path: ""
438+
module: mod.test/test@v0
439+
root: $CWD/testdata/testmod
440+
dir: ""
441+
display:""`}, {
442+
name: "ExplicitPackageWithUnqualifiedImportPath#2",
443+
// This test replicates the failure reported in https://cuelang.org/issue/3213
444+
cfg: &Config{
445+
Dir: filepath.Join(testdataDir, "multi2"),
446+
Package: "other",
447+
},
448+
args: []string{"."},
449+
want: `err: mod.test/test/multi2@v0:other: import failed: no dependency found for package "mod.test/test/sub":
450+
$CWD/testdata/testmod/multi2/other.cue:3:8
451+
path: mod.test/test/multi2@v0:other
452+
module: mod.test/test@v0
453+
root: $CWD/testdata/testmod
454+
dir: $CWD/testdata/testmod/multi2
455+
display:.
456+
files:
457+
$CWD/testdata/testmod/multi2/other.cue`}, {
458+
name: "ExplicitPackageWithUnqualifiedImportPath#3",
459+
cfg: &Config{
460+
Dir: filepath.Join(testdataDir, "multi3"),
461+
Package: "other",
462+
},
463+
args: []string{"."},
464+
want: `err: found packages "multi3" (multi3.cue) and "other" (other.cue) in "multi3"
465+
path: ""
466+
module: mod.test/test@v0
467+
root: $CWD/testdata/testmod
468+
dir: ""
429469
display:""`}}
430470
tdtest.Run(t, testCases, func(t *tdtest.T, tc *loadTest) {
431471
pkgs := Instances(tc.args, tc.cfg)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package other
2+
3+
import "mod.test/test/sub"
4+
5+
// This is a non-default package for the directory.
6+
7+
x: sub
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package multi3
2+
3+
// This is the default package for the directory.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package other
2+
3+
import "mod.test/test/sub"
4+
5+
// This is a non-default package for the directory.
6+
7+
x: sub

0 commit comments

Comments
 (0)