cue/load: do not create packages unnecessarily for files outside package directory
The current logic creates instances for files outside a package's
directory even when those have nothing to do with the package in
question.
Change the logic so that when a file in a parent directory is added, an
instance is only created when that file's package matches one of the
packages in the original directory.
Note: this is only an issue when `PkgName` is set to `*` to load all
packages.
Note also: this fixes some of the existing behavior, as witness the
other test result changes that mention `anon.cue` where that file is
actually irrelevant and should not be included as part of the instance
(packageless CUE files never include packageless CUE files from parent
directories).
Fixes #3306
Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I7f158b70f5d64068aa031b063aaca5680d738132
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198686
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>