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

Commit

Permalink
gps: check wildcard ignored and required conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
darkowlzz committed Sep 29, 2017
1 parent 1e70d28 commit 560c6b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/gps/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,13 @@ func (params SolveParameters) toRootdata() (rootdata, error) {
rd.ovr = make(ProjectConstraints)
}

// Create ignore prefix tree using the provided ignore packages
rd.igpfx = pkgtree.CreateIgnorePrefixTree(rd.ig)

if len(rd.ig) != 0 {
var both []string
for pkg := range params.Manifest.RequiredPackages() {
if rd.ig[pkg] {
if rd.isIgnored(pkg) {
both = append(both, pkg)
}
}
Expand Down Expand Up @@ -262,9 +265,6 @@ func (params SolveParameters) toRootdata() (rootdata, error) {
rd.chng[p] = struct{}{}
}

// Create ignore prefix tree using the provided ignore packages
rd.igpfx = pkgtree.CreateIgnorePrefixTree(rd.ig)

return rd, nil
}

Expand Down
11 changes: 11 additions & 0 deletions internal/gps/solver_inputs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ func TestBadSolveOpts(t *testing.T) {
} else if !strings.Contains(err.Error(), "multiple packages given as both required and ignored:") {
t.Error("Prepare should have given error with multiple ignore/require conflict error, but gave:", err)
}

params.Manifest = simpleRootManifest{
ig: map[string]bool{"foo*": true},
req: map[string]bool{"foo/bar": true},
}
_, err = Prepare(params, sm)
if err == nil {
t.Errorf("Should have errored on pkg both ignored (with wildcard) and required")
} else if !strings.Contains(err.Error(), "was given as both a required and ignored package") {
t.Error("Prepare should have given error with single ignore/require conflict error, but gave:", err)
}
params.Manifest = nil

params.ToChange = []ProjectRoot{"foo"}
Expand Down

0 comments on commit 560c6b5

Please sign in to comment.