Skip to content
This repository has been archived by the owner on Feb 3, 2018. It is now read-only.

Introduce 'requires' #114

Merged
merged 6 commits into from
Dec 13, 2016
Merged
Changes from 1 commit
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
93 changes: 93 additions & 0 deletions solve_bimodal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,97 @@ var bimodalFixtures = map[string]bimodalFixture{
"bar from baz 1.0.0",
),
},
"require package": {
ds: []depspec{
dsp(mkDepspec("root 0.0.0", "bar 1.0.0"),
pkg("root", "foo")),
dsp(mkDepspec("foo 1.0.0"),
pkg("foo", "bar")),
dsp(mkDepspec("bar 1.0.0"),
pkg("bar")),
dsp(mkDepspec("baz 1.0.0"),
pkg("baz")),
},
require: []string{"baz"},
r: mksolution(
"foo 1.0.0",
"bar 1.0.0",
"baz 1.0.0",
),
},
"require subpackage": {
ds: []depspec{
dsp(mkDepspec("root 0.0.0", "bar 1.0.0"),
pkg("root", "foo")),
dsp(mkDepspec("foo 1.0.0"),
pkg("foo", "bar")),
dsp(mkDepspec("bar 1.0.0"),
pkg("bar")),
dsp(mkDepspec("baz 1.0.0"),
pkg("baz", "baz/qux"),
pkg("baz/qux")),
},
require: []string{"baz/qux"},
r: mksolution(
"foo 1.0.0",
"bar 1.0.0",
mklp("baz 1.0.0", "baz/qux"),
),
},
"require impossible subpackage": {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This brings us back to another variant of a familiar question - if an unimported dep is constrained in the manifest, does that constraint still come into effect?

I think it's pretty clear in this case, though: having the requires list is basically equivalent to having an import path, and these are both emerging from the same manifest (so we can assume the same user has control over it), thus the constraint should be applied. And because deps can't express requires, we don't have the same transitivity problem as with normal imports.

ds: []depspec{
dsp(mkDepspec("root 0.0.0", "baz 1.0.0"),
pkg("root", "foo")),
dsp(mkDepspec("foo 1.0.0"),
pkg("foo")),
dsp(mkDepspec("baz 1.0.0"),
pkg("baz")),
dsp(mkDepspec("baz 2.0.0"),
pkg("baz", "baz/qux"),
pkg("baz/qux")),
},
require: []string{"baz/qux"},
fail: &noVersionError{
pn: mkPI("baz"),
//fails: , // TODO new fail type for failed require
},
},
"require subpkg conflicts with other dep constraint": {
ds: []depspec{
dsp(mkDepspec("root 0.0.0"),
pkg("root", "foo")),
dsp(mkDepspec("foo 1.0.0", "baz 1.0.0"),
pkg("foo", "baz")),
dsp(mkDepspec("baz 1.0.0"),
pkg("baz")),
dsp(mkDepspec("baz 2.0.0"),
pkg("baz", "baz/qux"),
pkg("baz/qux")),
},
require: []string{"baz/qux"},
fail: &noVersionError{
pn: mkPI("baz"),
//fails: , // TODO new fail type for failed require
},
},
"require independent subpkg conflicts with other dep constraint": {
ds: []depspec{
dsp(mkDepspec("root 0.0.0"),
pkg("root", "foo")),
dsp(mkDepspec("foo 1.0.0", "baz 1.0.0"),
pkg("foo", "baz")),
dsp(mkDepspec("baz 1.0.0"),
pkg("baz")),
dsp(mkDepspec("baz 2.0.0"),
pkg("baz"),
pkg("baz/qux")),
},
require: []string{"baz/qux"},
fail: &noVersionError{
pn: mkPI("baz"),
//fails: , // TODO new fail type for failed require
},
},
}

// tpkg is a representation of a single package. It has its own import path, as
Expand Down Expand Up @@ -783,6 +874,8 @@ type bimodalFixture struct {
changeall bool
// pkgs to ignore
ignore []string
// pkgs to require
require []string
}

func (f bimodalFixture) name() string {
Expand Down