This repository has been archived by the owner on Sep 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gps/verify: Add tests for LockSatisfaction
Also better prepare it for public consumption by exporting its members, renaming some methods and improving docs.
- Loading branch information
Showing
5 changed files
with
391 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package verify | ||
|
||
import ( | ||
"github.com/golang/dep/gps" | ||
"github.com/golang/dep/gps/pkgtree" | ||
) | ||
|
||
// mkPI creates a ProjectIdentifier with the ProjectRoot as the provided | ||
// string, and the Source unset. | ||
// | ||
// Call normalize() on the returned value if you need the Source to be be | ||
// equal to the ProjectRoot. | ||
func mkPI(root string) gps.ProjectIdentifier { | ||
return gps.ProjectIdentifier{ | ||
ProjectRoot: gps.ProjectRoot(root), | ||
} | ||
} | ||
|
||
type safeLock struct { | ||
p []gps.LockedProject | ||
i []string | ||
} | ||
|
||
func (sl safeLock) InputImports() []string { | ||
return sl.i | ||
} | ||
|
||
func (sl safeLock) Projects() []gps.LockedProject { | ||
return sl.p | ||
} | ||
|
||
// simpleRootManifest exists so that we have a safe value to swap into solver | ||
// params when a nil Manifest is provided. | ||
type simpleRootManifest struct { | ||
c, ovr gps.ProjectConstraints | ||
ig *pkgtree.IgnoredRuleset | ||
req map[string]bool | ||
} | ||
|
||
func (m simpleRootManifest) DependencyConstraints() gps.ProjectConstraints { | ||
return m.c | ||
} | ||
func (m simpleRootManifest) Overrides() gps.ProjectConstraints { | ||
return m.ovr | ||
} | ||
func (m simpleRootManifest) IgnoredPackages() *pkgtree.IgnoredRuleset { | ||
return m.ig | ||
} | ||
func (m simpleRootManifest) RequiredPackages() map[string]bool { | ||
return m.req | ||
} | ||
|
||
func (m simpleRootManifest) dup() simpleRootManifest { | ||
m2 := simpleRootManifest{ | ||
c: make(gps.ProjectConstraints), | ||
ovr: make(gps.ProjectConstraints), | ||
ig: pkgtree.NewIgnoredRuleset(m.ig.ToSlice()), | ||
req: make(map[string]bool), | ||
} | ||
|
||
for k, v := range m.c { | ||
m2.c[k] = v | ||
} | ||
|
||
for k, v := range m.ovr { | ||
m2.ovr[k] = v | ||
} | ||
|
||
for k := range m.req { | ||
m2.req[k] = true | ||
} | ||
|
||
return m2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.