Skip to content

Commit

Permalink
cmd/cue: add test for issue 3155
Browse files Browse the repository at this point in the history
This test will fail if the package resolution logic scans all packages
in the module, as reported in https://cuelang.org/issue/3155.

We add the test now so we can see that it's fixed in a subsequent CL.

For #3155.

Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I57d320cb0f4fdf656fdd5f5f41d1cf150fe6813d
  • Loading branch information
rogpeppe authored and mvdan committed May 28, 2024
1 parent 6661949 commit 80be1c8
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions cmd/cue/cmd/testdata/script/pkg_resolution_focus.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Test that only packages explicitly implied from command line
# arguments and their dependencies are scanned.
# See https://cuelang.org/issue/3155 for context.

# TODO: this should not fail.
! exec cue eval ./a

cmp stderr stderr.golden
-- stderr.golden --
cannot enumerate all module imports: cannot read "c/invalid.cue": expected 'STRING', found 'INT' 435
-- cue.mod/module.cue --
module: "mod.com"
language: version: "v0.9.0"
deps: "example.com/foo": v: "v0.0.1"
-- root.cue --
package root

import "mod.com/x"

x
-- a/a.cue --
package a

import "mod.com/b"

b
-- b/b.cue --
package b
import "example.com/foo"
b: 5
foo
-- c/invalid.cue --
// This file should be ignored because it's not part of the dependencies
// mentioned on the command line.
// We use invalid syntax to surface an error if the file is not ignored as expected.
package c
import 435

-- _registry/example.com_foo_v0.0.1/cue.mod/module.cue --
module: "example.com/foo@v0"
language: version: "v0.8.0"

-- _registry/example.com_foo_v0.0.1/foo.cue --
package foo
foo: true

0 comments on commit 80be1c8

Please sign in to comment.