diff --git a/internal/mod/modimports/modimports_test.go b/internal/mod/modimports/modimports_test.go index afa38875d2e..0bd16b15e15 100644 --- a/internal/mod/modimports/modimports_test.go +++ b/internal/mod/modimports/modimports_test.go @@ -90,6 +90,11 @@ import "other" -- omitted -- -- y.cue -- package y +-- sub/x.cue -- +package x +import ( + "imported-from-sub.com/foo" +) `)) tfs := txtarfs.FS(dirContents) imps, err := AllImports(PackageFiles(tfs, ".", "*")) @@ -111,4 +116,7 @@ package y imps, err = AllImports(PackageFiles(tfs, "foo", "*")) qt.Assert(t, qt.IsNil(err)) qt.Assert(t, qt.DeepEquals(imps, []string{"other"})) + imps, err = AllImports(PackageFiles(tfs, "sub", "x")) + qt.Assert(t, qt.IsNil(err)) + qt.Assert(t, qt.DeepEquals(imps, []string{"imported-from-sub.com/foo"})) } diff --git a/internal/mod/modimports/testdata/simple.txtar b/internal/mod/modimports/testdata/simple.txtar index ecf651e5191..409ea982d2f 100644 --- a/internal/mod/modimports/testdata/simple.txtar +++ b/internal/mod/modimports/testdata/simple.txtar @@ -4,6 +4,7 @@ y/y1.cue "dep3" "dep4" y/y2.cue y/z1.cue y/z2.cue +z.cue -- want-imports -- dep1 dep2:a @@ -40,6 +41,9 @@ package z -- y/z2.cue -- package z +-- z.cue -- +package example + -- _omitted1/foo.cue -- not even looked at diff --git a/internal/mod/modload/testdata/tidy/canuseprerelease.txtar b/internal/mod/modload/testdata/tidy/canuseprerelease.txtar index 3ab167e8113..98b2d1b77a3 100644 --- a/internal/mod/modload/testdata/tidy/canuseprerelease.txtar +++ b/internal/mod/modload/testdata/tidy/canuseprerelease.txtar @@ -2,7 +2,7 @@ # no stable releases available. -- tidy-check-error -- -module is not tidy: cannot find module providing package example.com@v0 +module is not tidy: cannot find module providing package example.com@v0:main -- want -- module: "main.org@v0" language: { @@ -20,7 +20,7 @@ language: version: "v0.8.0" -- main.cue -- package main -import "example.com@v0" +import "example.com@v0:main" -- _registry/example.com_v0.0.1-foo/cue.mod/module.cue -- module: "example.com@v0" diff --git a/internal/mod/modload/testdata/tidy/implied-major-version-with-explicit-default.txtar b/internal/mod/modload/testdata/tidy/implied-major-version-with-explicit-default.txtar index b8f903fa4ad..2cba107b8d7 100644 --- a/internal/mod/modload/testdata/tidy/implied-major-version-with-explicit-default.txtar +++ b/internal/mod/modload/testdata/tidy/implied-major-version-with-explicit-default.txtar @@ -26,7 +26,7 @@ deps: { -- main.cue -- package main -import "example.com" +import "example.com:main" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" diff --git a/internal/mod/modload/testdata/tidy/preferstable.txtar b/internal/mod/modload/testdata/tidy/preferstable.txtar index 752f39ee1e0..418ca21919b 100644 --- a/internal/mod/modload/testdata/tidy/preferstable.txtar +++ b/internal/mod/modload/testdata/tidy/preferstable.txtar @@ -22,7 +22,7 @@ language: { -- main.cue -- package main -import "example.com@v0" +import "example.com@v0:main" -- _registry/example.com_v0.0.1/cue.mod/module.cue -- module: "example.com@v0" diff --git a/internal/mod/modpkgload/testdata/multidir.txtar b/internal/mod/modpkgload/testdata/multidir.txtar new file mode 100644 index 00000000000..6c4af43108e --- /dev/null +++ b/internal/mod/modpkgload/testdata/multidir.txtar @@ -0,0 +1,32 @@ +-- test0/initial-requirements -- +main.test@v0 +example.com@v0.0.1 +-- test0/root-packages -- +main.test@v0:main +-- test0/default-major-versions -- +-- test0/want -- +main.test@v0:main + flags: inAll,isRoot,fromRoot,importsLoaded + mod: main.test@v0 + location: . + imports: + example.com/blah@v0 +example.com/blah@v0 + flags: inAll,isRoot,fromRoot,importsLoaded + mod: example.com@v0.0.1 + location: _registry/example.com_v0.0.1/blah +-- main.cue -- +package main +import "example.com/blah@v0" + +-- _registry/example.com_v0.0.1/cue.mod/module.cue -- +module: "example.com@v0" +language: version: "v0.8.0" +-- _registry/example.com_v0.0.1/blah/blah.cue -- +package blah +-- _registry/example.com_v0.0.1/x.cue -- +package blah +import _ "foo.com/bar/hello/goodbye@v0" +-- _registry/example.com_v0.0.1/y.cue -- +package other +import _ "foo.com/bar/somethingelse@v0" diff --git a/internal/mod/modpkgload/testdata/nocuefiles.txtar b/internal/mod/modpkgload/testdata/nocuefiles.txtar new file mode 100644 index 00000000000..b3fe10a82d1 --- /dev/null +++ b/internal/mod/modpkgload/testdata/nocuefiles.txtar @@ -0,0 +1,28 @@ +-- test0/initial-requirements -- +main.test@v0 +example.com@v0.0.1 +-- test0/root-packages -- +main.test@v0:main +-- test0/default-major-versions -- +-- test0/want -- +main.test@v0:main + flags: inAll,isRoot,fromRoot,importsLoaded + mod: main.test@v0 + location: . + imports: + example.com/blah@v0 +example.com/blah@v0 + flags: inAll,isRoot,fromRoot,importsLoaded + mod: example.com@v0.0.1 + location: _registry/example.com_v0.0.1/blah +-- main.cue -- +package main +import "example.com/blah@v0" + +-- _registry/example.com_v0.0.1/cue.mod/module.cue -- +module: "example.com@v0" +language: version: "v0.8.0" +-- _registry/example.com_v0.0.1/blah/x.cue -- +package a +-- _registry/example.com_v0.0.1/blah/other/other.cue -- +package b