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

[ready to review] v2 feature resolver #126

Merged
merged 5 commits into from
May 6, 2020

Conversation

sunshowers
Copy link
Contributor

@sunshowers sunshowers commented May 1, 2020

Includes:

  • The v2 resolver itself
  • extensive proptests against real repos -- both a small test repo and the cargo-guppy repo itself!

Of particular interest are two points of note between the V1 and V2 resolvers that I thought were surprising:

  1. Build dependencies are considered by the feature resolver even if there's no build script. (In V1 they're only considered if there's a build script.)
  2. For initials, if dev dependencies are included, they're also considered for the host, not just the target.

I'll file issues against the cargo repo soon.

This ended up being really straightforward! I discovered a couple of
behavior differences around the presence of build scripts -- it would be
interesting to report this upstream.

Upstream cargo had some fixes that I ended up having to pull in, hence the
git dependency.
Also include a failed attempt to allow setting a custom
home dir (sorry!)
@sunshowers sunshowers changed the title [WIP, almost ready] v2 feature resolver [ready to review] v2 feature resolver May 1, 2020
@sunshowers sunshowers requested review from bmwill and metajack May 1, 2020 23:40
@@ -351,6 +351,98 @@ impl<'a> CargoSetBuildState<'a> {
}
}

fn new_v2(self, query: FeatureQuery<'_>) -> CargoSet {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The core algorithm starts here. Note the XXX marks about whether some cases are bugs in upstream cargo.

@sunshowers sunshowers force-pushed the cargosim-v2 branch 14 times, most recently from 73961df to 51e26b1 Compare May 3, 2020 19:51
pub fn triple_strategy() -> impl Strategy<Value = Option<&'static str>> {
// Filter out Apple platforms because rustc requires the Apple SDKs to be set up for them.
let platform_strategy = Platform::filtered_strategy(
|triple| !triple.contains("-apple-"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

:(

bors added a commit to rust-lang/cargo that referenced this pull request May 5, 2020
features: allow activated_features_unverified to communicate not-present

Hi there! :)

I'm currently writing [`cargo-guppy`](https://github.com/facebookincubator/cargo-guppy), a toolkit for analyzing Rust dependency graphs. As part of that I'm writing some tests to compare guppy to `cargo` (see facebookarchive/cargo-guppy#126), to ensure that it produces the same results for the subset of analyses `cargo` can do.

While writing tests I found it useful to distinguish between packages that weren't present at all and packages that were activated but with no features. This commit adds that functionality to the `_unverified` method.

(BTW, of possible interest to @ehuss, I've also found some interesting behavior differences between the v1 and v2 resolvers. Will file issues for them soon!)
This works by:
* setting up a real, fairly complex fixture
* generating random queries using proptest
* running them through cargo and guppy
* ensuring that they produce the same results

Not only does this give us high confidence that cargo
and guppy produce the same results, it also gets us
most of the way to facebookarchive#83.

Most of the work in this commit is simply setting up
all the necessary test infrastructure. We piggy-back on
existing proptest infrastructure as much as possible.
Do this in a separate job to allow for greater parallelization.
Make proptests more interesting by generating random platforms for tests.
Copy link
Contributor

@metajack metajack left a comment

Choose a reason for hiding this comment

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

All looks good. Love all the new tests!

@sunshowers sunshowers merged commit d8158c5 into facebookarchive:master May 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants