Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
allow dirs that don't contain go files
Browse files Browse the repository at this point in the history
  • Loading branch information
travisjeffery committed Nov 23, 2017
1 parent 13df556 commit 509d460
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
["init", "-no-examples", "-skip-tools"],
["ensure", "-update"]
],
"error-expected": "no dirs contained any Go code",
"error-expected": "",
"vendor-final": []
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"commands": [
["ensure"]
],
"error-expected": "found 1 errors",
"error-expected": "",
"vendor-final": []
}
4 changes: 0 additions & 4 deletions gps/pkgtree/pkgtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ func fillPackage(p *build.Package) error {
return err
}

if len(gofiles) == 0 {
return &build.NoGoError{Dir: p.Dir}
}

var testImports []string
var imports []string
var importComments []string
Expand Down
23 changes: 12 additions & 11 deletions gps/pkgtree/pkgtree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package pkgtree

import (
"fmt"
"go/build"
"go/scanner"
"go/token"
"io/ioutil"
Expand All @@ -18,6 +17,7 @@ import (
"strings"
"testing"

"github.com/davecgh/go-spew/spew"
"github.com/golang/dep/gps/paths"
"github.com/golang/dep/internal/fs"
)
Expand Down Expand Up @@ -489,8 +489,9 @@ func TestListPackages(t *testing.T) {
ImportRoot: "empty",
Packages: map[string]PackageOrErr{
"empty": {
Err: &build.NoGoError{
Dir: j("empty"),
P: Package{
ImportPath: "empty",
Imports: []string{},
},
},
},
Expand Down Expand Up @@ -733,8 +734,9 @@ func TestListPackages(t *testing.T) {
ImportRoot: "ren",
Packages: map[string]PackageOrErr{
"ren": {
Err: &build.NoGoError{
Dir: j("ren"),
P: Package{
ImportPath: "ren",
Imports: []string{},
},
},
"ren/m1p": {
Expand Down Expand Up @@ -1653,8 +1655,9 @@ func TestListPackagesNoPerms(t *testing.T) {
ImportRoot: "ren",
Packages: map[string]PackageOrErr{
"ren": {
Err: &build.NoGoError{
Dir: workdir,
P: Package{
ImportPath: "ren",
Imports: []string{},
},
},
"ren/m1p": {
Expand All @@ -1673,6 +1676,8 @@ func TestListPackagesNoPerms(t *testing.T) {

got, err := ListPackages(workdir, "ren")

spew.Dump(got)

if err != nil {
t.Fatalf("Unexpected err from ListPackages: %s", err)
}
Expand All @@ -1690,10 +1695,6 @@ func TestListPackagesNoPerms(t *testing.T) {
}
}

if got.Packages["ren"].Err == nil {
t.Error("Should have gotten error on empty root directory")
}

if !reflect.DeepEqual(got.Packages["ren/m1p"].P.Imports, want.Packages["ren/m1p"].P.Imports) {
t.Error("Mismatch between imports in m1p")
}
Expand Down

0 comments on commit 509d460

Please sign in to comment.