From f40f8c662a8376021e7e10a6f58f939bea2616ac Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 7 Oct 2016 12:43:48 -0700 Subject: [PATCH] Add a test for deprecation warnings --- tests/registry.rs | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/tests/registry.rs b/tests/registry.rs index 34150a856b5..e95dc1e49ea 100644 --- a/tests/registry.rs +++ b/tests/registry.rs @@ -1242,3 +1242,101 @@ fn bump_version_dont_update_registry() { [FINISHED] [..] ")); } + +#[test] +fn old_version_req() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.5.0" + authors = [] + + [dependencies] + remote = "0.2*" + "#) + .file("src/main.rs", "fn main() {}"); + p.build(); + + Package::new("remote", "0.2.0").publish(); + + assert_that(p.cargo("build"), + execs().with_status(0) + .with_stderr("\ +warning: parsed version requirement `0.2*` is no longer valid + +Previous versions of Cargo accepted this malformed requirement, +but it is being deprecated. This was found when parsing the manifest +of bar 0.5.0, and the correct version requirement is `0.2.*`. + +This will soon become a hard error, so it's either recommended to +update to a fixed version or contact the upstream maintainer about +this warning. + +warning: parsed version requirement `0.2*` is no longer valid + +Previous versions of Cargo accepted this malformed requirement, +but it is being deprecated. This was found when parsing the manifest +of bar 0.5.0, and the correct version requirement is `0.2.*`. + +This will soon become a hard error, so it's either recommended to +update to a fixed version or contact the upstream maintainer about +this warning. + +[UPDATING] [..] +[DOWNLOADING] [..] +[COMPILING] [..] +[COMPILING] [..] +[FINISHED] [..] +")); +} + +#[test] +fn old_version_req_upstream() { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "bar" + version = "0.5.0" + authors = [] + + [dependencies] + remote = "0.3" + "#) + .file("src/main.rs", "fn main() {}"); + p.build(); + + Package::new("remote", "0.3.0") + .file("Cargo.toml", r#" + [project] + name = "remote" + version = "0.3.0" + authors = [] + + [dependencies] + bar = "0.2*" + "#) + .file("src/lib.rs", "") + .publish(); + Package::new("bar", "0.2.0").publish(); + + assert_that(p.cargo("build"), + execs().with_status(0) + .with_stderr("\ +[UPDATING] [..] +[DOWNLOADING] [..] +warning: parsed version requirement `0.2*` is no longer valid + +Previous versions of Cargo accepted this malformed requirement, +but it is being deprecated. This was found when parsing the manifest +of remote 0.3.0, and the correct version requirement is `0.2.*`. + +This will soon become a hard error, so it's either recommended to +update to a fixed version or contact the upstream maintainer about +this warning. + +[COMPILING] [..] +[COMPILING] [..] +[FINISHED] [..] +")); +}