Skip to content

Commit

Permalink
ast/astutil: add test for resolving imports with major version suffix
Browse files Browse the repository at this point in the history
Currently astutil.Resolve does not understand major version
suffixes, leading to problems with round-tripping files
through astutil.Sanitize.

We a test for this to be fixed by a subsequent CL.

Signed-off-by: Roger Peppe <[email protected]>
Change-Id: I89e49348cc357cc84ffb059facfa70e632bfdf4f
Dispatch-Trailer: {"type":"trybot","CL":1207986,"patchset":5,"ref":"refs/changes/86/1207986/5","targetBranch":"master"}
  • Loading branch information
rogpeppe authored and cueckoo committed Jan 30, 2025
1 parent 0d31535 commit 0f8be25
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cue/ast/astutil/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestResolve(t *testing.T) {
}

test.Run(t, func(t *cuetxtar.Test) {
a := t.Instance()
a := t.RawInstances()[0]

for _, f := range a.Files {
if filepath.Ext(f.Filename) != ".cue" {
Expand Down
19 changes: 19 additions & 0 deletions cue/ast/astutil/testdata/resolve/import.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- in.cue --
import (
"foo.com/bar"
"foo.com/bar:baz"
"other.org/p@v1"
"other.org/p@v2:q"
)
refs: [
bar,
baz,
p,
q,
]
-- out/resolve/in --
7[refs]: Scope: 0[<nil>] Node: 0[]
8[bar]: Scope: 0[<nil>] Node: 2["foo.com/bar"]
9[baz]: Scope: 0[<nil>] Node: 3["foo.com/bar:baz"]
10[p]: Scope: 0[<nil>] Node: 0[]
11[q]: Scope: 0[<nil>] Node: 5["other.org/p@v2:q"]

0 comments on commit 0f8be25

Please sign in to comment.