Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
cmd/cue/cmd: include tool and test files in fix
Browse files Browse the repository at this point in the history
This is semantically not entirely correct, but is unlikely
to give issues.

Change-Id: Iaad6de25160a6c92e9ddc7d81a36bbd3fbe3d379
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6440
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Jun 18, 2020
1 parent d3c0096 commit ab43a15
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/cue/cmd/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,17 @@ func runFixAll(cmd *Command, args []string) error {
}
}

instances := load.Instances(args, &load.Config{})
instances := load.Instances(args, &load.Config{
Tests: true,
Tools: true,
})

for _, i := range instances {
a := append(i.ToolCUEFiles, i.TestCUEFiles...)
for _, f := range a {
file := i.Abs(f)
_ = i.AddFile(file, nil)
}
if i.Err != nil {
return i.Err
}
Expand Down
20 changes: 20 additions & 0 deletions cmd/cue/cmd/testdata/script/fix.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cue fix

cmp foo/foo.cue expect/foo/foo_cue
cmp foo/foo_test.cue expect/foo/foo_test_cue
cmp foo/foo_tool.cue expect/foo/foo_tool_cue
cmp bar/bar.cue expect/bar/bar_cue
cmp cue.mod/pkg/foobar.org/notimported/notimported.cue expect/cue.mod/pkg/foobar.org/notimported/notimported.cue
cmp cue.mod/gen/foobar.org/imported/imported.cue expect/cue.mod/gen/foobar.org/imported/imported.cue
Expand Down Expand Up @@ -52,6 +54,24 @@ Def :: {
a: Def
c: [Def.b]: int

-- foo/foo_test.cue --
package foo

A :: int

-- expect/foo/foo_test_cue --
package foo

#A: int
-- foo/foo_tool.cue --
package foo

B :: int

-- expect/foo/foo_tool_cue --
package foo

#B: int
-- expect/bar/bar_cue --
package bar

Expand Down

0 comments on commit ab43a15

Please sign in to comment.