Skip to content

Commit

Permalink
Add test for prototool files (uber#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev authored Apr 15, 2019
1 parent 7940d2e commit 30bfb8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions internal/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,11 @@ func TestDiffLintGroups(t *testing.T) {
)
}

func TestFiles(t *testing.T) {
assertExact(t, false, false, 0, `testdata/foo/bar/dep.proto
testdata/foo/success.proto`, "files", "testdata/foo")
}

func TestGenerateDescriptorSetSameDirAsConfigFile(t *testing.T) {
t.Parallel()
// https://github.com/uber/prototool/issues/389
Expand Down
11 changes: 8 additions & 3 deletions internal/exec/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,20 @@ func (r *runner) Files(args []string) error {
if err != nil {
return err
}
var allFiles []string
for dirPath, files := range meta.ProtoSet.DirPathToFiles {
// skip those files not under the directory
if !strings.HasPrefix(dirPath, meta.ProtoSet.DirPath) {
continue
}
for _, file := range files {
if err := r.println(file.DisplayPath); err != nil {
return err
}
allFiles = append(allFiles, file.DisplayPath)
}
}
sort.Strings(allFiles)
for _, file := range allFiles {
if err := r.println(file); err != nil {
return err
}
}
return nil
Expand Down

0 comments on commit 30bfb8c

Please sign in to comment.