-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cue/load: better treatment of files specified on the command line
Currently in modules mode, imports in files specified on the command line are not added to the set of root packages. Also, the entire module is always considered even when a file specified on the command line doesn't use any of it. This CL addresses these issues by walking the imports of files explicitly specified on the command line, and by avoiding loading all module imports when there are only files specified on the command line. This is not a complete solution: it is also desirable that we walk the dependencies of only the packages and files that are explicitly mentioned on the command line, but doing that would require a considerable refactor and for now, it is likely that mixing CUE files and packages together on the command line is somewhat rare, so walking all module imports whenever a package is specified on the command line should be sufficient. Fixes #3144 Fixes #3147 Signed-off-by: Roger Peppe <[email protected]> Change-Id: Ie6236aeadfb14fc891eec2f4e6a905c7b37583bb Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194765 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
- Loading branch information
Showing
7 changed files
with
145 additions
and
31 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
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,22 @@ | ||
# Check that unrelated invalid files do not cause an error when only files | ||
# are specified on the command line. | ||
|
||
env CUE_EXPERIMENT=modules | ||
env CUE_CACHE_DIR=$WORK/tmp/cache | ||
|
||
exec cue export valid.cue | ||
cmp stdout stdout.golden | ||
|
||
-- stdout.golden -- | ||
{ | ||
"out": "bar" | ||
} | ||
-- cue.mod/module.cue -- | ||
module: "foo.test/bar" | ||
language: version: "v0.9.0" | ||
-- valid.cue -- | ||
#foo: "bar" | ||
out: #foo | ||
-- invalid.cue -- | ||
foo :: "bar" | ||
out: foo |
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 @@ | ||
# Check that imports from files specified on the command line | ||
# are still considered even when they are not part of the main module. | ||
|
||
env CUE_EXPERIMENT=modules | ||
env CUE_CACHE_DIR=$WORK/tmp/cache | ||
exec cue export _foo/x.cue | ||
cmp stdout stdout.golden | ||
|
||
-- cue.mod/module.cue -- | ||
module: "mod.com@v0" | ||
language: { | ||
version: "v0.9.0" | ||
} | ||
-- cue.mod/pkg/example.com/banana/banana.cue -- | ||
package banana | ||
|
||
X: 42 | ||
-- _foo/x.cue -- | ||
package p | ||
|
||
import "example.com/banana" | ||
|
||
x: banana.X | ||
-- stdout.golden -- | ||
{ | ||
"x": 42 | ||
} |
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
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
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
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