Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Jun 5, 2017
1 parent e3835f7 commit a389d48
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/cargo/core/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,12 @@ pub mod test {
let overrides = self.query_overrides(dep);

if overrides.is_empty() {
self.summaries.query(dep, f)
for s in self.summaries.iter() {
if dep.matches(s) {
f(s.clone());
}
}
Ok(())
} else {
for s in overrides {
f(s);
Expand Down
22 changes: 18 additions & 4 deletions tests/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,26 @@ use cargo::core::{Dependency, PackageId, Summary, Registry};
use cargo::util::{CargoResult, ToUrl};
use cargo::core::resolver::{self, Method};

fn resolve<R: Registry>(pkg: PackageId, deps: Vec<Dependency>,
registry: &mut R)
-> CargoResult<Vec<PackageId>> {
fn resolve(pkg: PackageId, deps: Vec<Dependency>, registry: &[Summary])
-> CargoResult<Vec<PackageId>>
{
struct MyRegistry<'a>(&'a [Summary]);
impl<'a> Registry for MyRegistry<'a> {
fn query(&mut self,
dep: &Dependency,
f: &mut FnMut(Summary)) -> CargoResult<()> {
for summary in self.0.iter() {
if dep.matches(summary) {
f(summary.clone());
}
}
Ok(())
}
}
let mut registry = MyRegistry(registry);
let summary = Summary::new(pkg.clone(), deps, HashMap::new()).unwrap();
let method = Method::Everything;
let resolve = resolver::resolve(&[(summary, method)], &[], registry)?;
let resolve = resolver::resolve(&[(summary, method)], &[], &mut registry)?;
let res = resolve.iter().cloned().collect();
Ok(res)
}
Expand Down

0 comments on commit a389d48

Please sign in to comment.