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

dep ensure -add should not depend on Go code #1434

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ NEW FEATURES:
BUG FIXES:

IMPROVEMENTS:
* dep ensure does not depend on Go code (#1434)

# v0.4.1

Expand Down
4 changes: 2 additions & 2 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,9 @@ func checkErrors(m map[string]pkgtree.PackageOrErr, ignore *pkgtree.IgnoredRules
}
}

// If pkgtree was empty or all dirs lacked any Go code, return an error.
// If pkgtree was empty or all dirs lacked any Go code, return a warning.
if len(m) == 0 || len(m) == noGoErrors {
return true, errors.New("no dirs contained any Go code")
return false, errors.New("no dirs contained any Go code")
}

// If all dirs contained build errors, return an error.
Expand Down
11 changes: 8 additions & 3 deletions cmd/dep/ensure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func TestCheckErrors(t *testing.T) {
fatal bool
pkgOrErrMap map[string]pkgtree.PackageOrErr
}{
{
name: "noErrorsAndEmpty",
fatal: false,
pkgOrErrMap: map[string]pkgtree.PackageOrErr{},
},
{
name: "noErrors",
fatal: false,
Expand Down Expand Up @@ -112,7 +117,7 @@ func TestCheckErrors(t *testing.T) {
},
{
name: "allGoErrors",
fatal: true,
fatal: false,
pkgOrErrMap: map[string]pkgtree.PackageOrErr{
"github.com/me/pkg": {
Err: &build.NoGoError{},
Expand All @@ -137,10 +142,10 @@ func TestCheckErrors(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
fatal, err := checkErrors(tc.pkgOrErrMap, nil)
if tc.fatal != fatal {
t.Fatalf("expected fatal flag to be %T, got %T", tc.fatal, fatal)
t.Fatalf("%s: expected fatal flag to be %t, got %t", tc.name, tc.fatal, fatal)
}
if err == nil && fatal {
t.Fatal("unexpected fatal flag value while err is nil")
t.Fatalf("%s: unexpected fatal flag value while err is nil", tc.name)
}
})
}
Expand Down

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
@@ -0,0 +1,4 @@

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"commands": [
["init", "-no-examples", "-skip-tools"],
["ensure", "-add", "github.com/sdboyer/deptest"]
],
"error-expected": "",
"vendor-final": [
"github.com/sdboyer/deptest"
]
}

This file was deleted.

This file was deleted.

This file was deleted.