From: Eh2406 Date: Tue, 27 Feb 2018 15:08:19 +0000 (-0500) Subject: add a test for cargo/issues/4347 X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~2^2~70^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=834846901d651e8b82296bc2f470dd8596a1b01a;p=cargo.git add a test for cargo/issues/4347 --- diff --git a/tests/testsuite/resolve.rs b/tests/testsuite/resolve.rs index 55d683fee..c43277f24 100644 --- a/tests/testsuite/resolve.rs +++ b/tests/testsuite/resolve.rs @@ -58,20 +58,20 @@ trait ToPkgId { fn to_pkgid(&self) -> PackageId; } -impl ToPkgId for &'static str { +impl<'a> ToPkgId for &'a str { fn to_pkgid(&self) -> PackageId { PackageId::new(*self, "1.0.0", ®istry_loc()).unwrap() } } -impl ToPkgId for (&'static str, &'static str) { +impl<'a> ToPkgId for (&'a str, &'a str) { fn to_pkgid(&self) -> PackageId { let (name, vers) = *self; PackageId::new(name, vers, ®istry_loc()).unwrap() } } -impl ToPkgId for (&'static str, String) { +impl<'a> ToPkgId for (&'a str, String) { fn to_pkgid(&self) -> PackageId { let (name, ref vers) = *self; PackageId::new(name, vers, ®istry_loc()).unwrap() @@ -316,6 +316,27 @@ fn resolving_backtrack() { ("baz", "1.0.0")]))); } +#[test] +fn resolving_backtrack_features() { + // test for cargo/issues/4347 + let mut bad = dep("bar"); + bad.set_features(vec!["bad".to_string()]); + + let reg = registry(vec![ + pkg!(("foo", "1.0.2") => [bad]), + pkg!(("foo", "1.0.1") => [dep("bar")]), + pkg!("bar"), + ]); + + let res = resolve(&pkg_id("root"), vec![ + dep_req("foo", "^1"), + ], ®).unwrap(); + + assert_that(&res, contains(names(&[("root", "1.0.0"), + ("foo", "1.0.1"), + ("bar", "1.0.0")]))); +} + #[test] fn resolving_allows_multiple_compatible_versions() { let reg = registry(vec![