Skip to content

Commit

Permalink
Auto merge of #6962 - Eh2406:pub-dep-prop-tests, r=alexcrichton
Browse files Browse the repository at this point in the history
add public & private prop tests.

This is the code that checks that the resolver does not output a public & private conflict. We still do not have the gen of public dependencies do to 9b8b12c, because backtracking is to inefficient, but this checks that we are getting a correct answer.

This was supposed to be in #6653, but was lost in the edits of history.
Reconstructed from Eh2406@5522aba
  • Loading branch information
bors committed May 20, 2019
2 parents e7b3b67 + a02f6a1 commit d1b55ad
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/testsuite/support/resolver.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::cmp::PartialEq;
use std::cmp::{max, min};
use std::collections::{BTreeMap, HashSet};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::fmt;
use std::time::Instant;

Expand Down Expand Up @@ -54,6 +54,34 @@ pub fn resolve_and_validated(
}
let out = resolve.sort();
assert_eq!(out.len(), used.len());

let mut pub_deps: HashMap<PackageId, HashSet<_>> = HashMap::new();
for &p in out.iter() {
// make the list of `p` public dependencies
let mut self_pub_dep = HashSet::new();
self_pub_dep.insert(p);
for (dp, deps) in resolve.deps(p) {
if deps.iter().any(|d| d.is_public()) {
self_pub_dep.extend(pub_deps[&dp].iter().cloned())
}
}
pub_deps.insert(p, self_pub_dep);

// check if `p` has a public dependencies conflicts
let seen_dep: BTreeSet<_> = resolve
.deps(p)
.flat_map(|(dp, _)| pub_deps[&dp].iter().cloned())
.collect();
let seen_dep: Vec<_> = seen_dep.iter().collect();
for a in seen_dep.windows(2) {
if a[0].name() == a[1].name() {
panic!(
"the package {:?} can publicly see {:?} and {:?}",
p, a[0], a[1]
)
}
}
}
Ok(out)
}

Expand Down

0 comments on commit d1b55ad

Please sign in to comment.