Also restore a "reflect" import that got dropped.
This commit is contained in:
sam boyer 2016-07-26 23:15:48 -04:00
Родитель a1c8ddf528
Коммит 1423ffc917
7 изменённых файлов: 38 добавлений и 22 удалений

Просмотреть файл

@ -164,3 +164,10 @@ func (noneConstraint) MatchesAny(Constraint) bool {
func (noneConstraint) Intersect(Constraint) Constraint {
return none
}
type ProjectConstraints map[ProjectRoot]ProjectProperties
//func mergePCSlices( ProjectConstraints, wother ProjectConstraints) {
//final := make(ProjectConstraints)
//}

Просмотреть файл

@ -108,8 +108,8 @@ func TestHashInputsOverrides(t *testing.T) {
rm := fix.rootmanifest().(simpleRootManifest)
// First case - override something not in the root, just with network name
rm.ovr = map[ProjectRoot]Override{
"c": Override{
rm.ovr = map[ProjectRoot]ProjectProperties{
"c": ProjectProperties{
NetworkName: "car",
},
}
@ -157,7 +157,7 @@ func TestHashInputsOverrides(t *testing.T) {
}
// Override not in root, just with constraint
rm.ovr["d"] = Override{
rm.ovr["d"] = ProjectProperties{
Constraint: NewBranch("foobranch"),
}
dig, err = s.HashInputs()
@ -198,7 +198,7 @@ func TestHashInputsOverrides(t *testing.T) {
}
// Override not in root, both constraint and network name
rm.ovr["e"] = Override{
rm.ovr["e"] = ProjectProperties{
NetworkName: "groucho",
Constraint: NewBranch("plexiglass"),
}
@ -243,7 +243,7 @@ func TestHashInputsOverrides(t *testing.T) {
}
// Override in root, just constraint
rm.ovr["a"] = Override{
rm.ovr["a"] = ProjectProperties{
Constraint: NewVersion("fluglehorn"),
}
dig, err = s.HashInputs()
@ -287,7 +287,7 @@ func TestHashInputsOverrides(t *testing.T) {
}
// Override in root, only network name
rm.ovr["a"] = Override{
rm.ovr["a"] = ProjectProperties{
NetworkName: "nota",
}
dig, err = s.HashInputs()
@ -331,7 +331,7 @@ func TestHashInputsOverrides(t *testing.T) {
}
// Override in root, network name and constraint
rm.ovr["a"] = Override{
rm.ovr["a"] = ProjectProperties{
NetworkName: "nota",
Constraint: NewVersion("fluglehorn"),
}

Просмотреть файл

@ -16,8 +16,11 @@ package gps
type Manifest interface {
// Returns a list of project-level constraints.
DependencyConstraints() []ProjectConstraint
// Returns a list of constraints applicable to test imports. Note that this
// will only be consulted for root manifests.
// Returns a list of constraints applicable to test imports.
//
// These are applied only when tests are incorporated. Typically, that
// will only be for root manifests.
TestDependencyConstraints() []ProjectConstraint
}
@ -34,7 +37,7 @@ type RootManifest interface {
// users should be encouraged to use them only as a last resort; they do not
// "play well with others" (that is their express goal), and overreliance on
// them can harm the ecosystem as a whole.
Overrides() map[ProjectRoot]Override
Overrides() ProjectConstraints
// IngorePackages returns a set of import paths to ignore. These import
// paths can be within the root project, or part of other projects. Ignoring
@ -71,7 +74,7 @@ func (m SimpleManifest) TestDependencyConstraints() []ProjectConstraint {
type simpleRootManifest struct {
c []ProjectConstraint
tc []ProjectConstraint
ovr map[ProjectRoot]Override
ovr ProjectConstraints
ig map[string]bool
}
@ -81,7 +84,7 @@ func (m simpleRootManifest) DependencyConstraints() []ProjectConstraint {
func (m simpleRootManifest) TestDependencyConstraints() []ProjectConstraint {
return m.tc
}
func (m simpleRootManifest) Overrides() map[ProjectRoot]Override {
func (m simpleRootManifest) Overrides() ProjectConstraints {
return m.ovr
}
func (m simpleRootManifest) IgnorePackages() map[string]bool {

Просмотреть файл

@ -1042,6 +1042,7 @@ var basicFixtures = map[string]basicFixture{
"foo r123abc",
),
},
// TODO(sdboyer) decide how to refactor the solver in order to re-enable these.
// Checking for revision existence is important...but kinda obnoxious.
//{

Просмотреть файл

@ -6,6 +6,7 @@ import (
"log"
"math/rand"
"os"
"reflect"
"sort"
"strconv"
"strings"

Просмотреть файл

@ -151,7 +151,7 @@ type solver struct {
// A map of ProjectRoot (import path names) to the ProjectConstraint that
// should be enforced for those names.
ovr map[ProjectRoot]Override
ovr map[ProjectRoot]ProjectProperties
// A map of the names listed in the root's lock.
rlm map[ProjectIdentifier]LockedProject
@ -187,9 +187,6 @@ type Solver interface {
// with the inputs is detected, an error is returned. Otherwise, a Solver is
// returned, ready to hash and check inputs or perform a solving run.
func Prepare(params SolveParameters, sm SourceManager) (Solver, error) {
// local overrides would need to be handled first.
// TODO(sdboyer) local overrides! heh
if sm == nil {
return nil, badOptsFailure("must provide non-nil SourceManager")
}
@ -210,13 +207,17 @@ func Prepare(params SolveParameters, sm SourceManager) (Solver, error) {
s := &solver{
params: params,
ig: params.Manifest.IgnorePackages(),
ovr: params.Manifest.Overrides(),
tl: params.TraceLogger,
}
// Ensure the ignore map is at least initialized
// Ensure the ignore and overrides maps are at least initialized
if s.ig == nil {
s.ig = make(map[string]bool)
}
if s.ovr == nil {
s.ovr = make(map[ProjectRoot]ProjectProperties)
}
// Set up the bridge and ensure the root dir is in good, working order
// before doing anything else. (This call is stubbed out in tests, via
@ -551,8 +552,8 @@ func (s *solver) intersectConstraintsWithImports(deps []ProjectConstraint, reach
// github.com/sdboyer/foo
// github.com/sdboyer/foobar/baz
//
// The latter would incorrectly be conflated in with the former. So,
// as we know we're operating on strings that describe paths, guard
// The latter would incorrectly be conflated with the former. So, as
// we know we're operating on strings that describe paths, guard
// against this case by verifying that either the input is the same
// length as the match (in which case we know they're equal), or
// that the next character is the is the PathSeparator.

Просмотреть файл

@ -134,9 +134,12 @@ func (i ProjectIdentifier) normalize() ProjectIdentifier {
return i
}
// An Override can be provided by the RootManifest to designate a network name
// and constraint that should *always* be used for a given ProjectRoot.
type Override struct {
// ProjectProperties comprise the properties that can attached to a ProjectRoot.
//
// In general, these are declared in the context of a map of ProjectRoot to its
// ProjectProperties; they make little sense without their corresponding
// ProjectRoot.
type ProjectProperties struct {
NetworkName string
Constraint Constraint
}