Skip to content

Commit b193af0

Browse files
committed
cmd/cue: fix a regression with cue get go dropping CUE files
In https://cuelang.org/cl/1196294 I refactored the code to swap filepath.WalkDir for os.ReadDir, given that we didn't need to read directory trees recursively. However, I failed to realise that a `return nil` would be problematic when replacing a callback function with a regular for loop, as it now stopped the entire parent func. We didn't notice as the test used to happen to hide the bug; the improved test now shows that the bug is fixed. Fixes #3644. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Ia0ebafcf481402faf106af26fea507da98dae47c Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207330 Reviewed-by: Roger Peppe <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent c94fd55 commit b193af0

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

cmd/cue/cmd/get_go.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ func (e *extractor) importCUEFiles(p *packages.Package, dstDir, args string) err
595595
path := filepath.Join(srcDir, name)
596596
name, ok := strings.CutSuffix(name, ".cue")
597597
if !ok {
598-
return nil
598+
continue
599599
}
600600
f, err := parser.ParseFile(path, nil, parser.PackageClauseOnly)
601601
if err != nil {

cmd/cue/cmd/testdata/script/get_go_non_local.txtar

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ go mod tidy
1111
exec cue get go externalmod.test/mixfiles
1212
cmp cue.mod/gen/externalmod.test/mixfiles/code_one_go_gen.cue cue.mod/gen/externalmod.test/mixfiles/code_one_go_gen.cue.golden
1313
cmp cue.mod/gen/externalmod.test/mixfiles/code_two_go_gen.cue cue.mod/gen/externalmod.test/mixfiles/code_two_go_gen.cue.golden
14-
# TODO(mvdan): fix https://cuelang.org/issue/3644
15-
! exists cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue
16-
! exists cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue
17-
# cmp cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue.golden
18-
# cmp cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue.golden
14+
cmp cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue.golden
15+
cmp cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue.golden
1916

2017
# Verify dependencies are as expected
2118
cmp go.mod go.mod.golden

0 commit comments

Comments
 (0)