Skip to content

Commit f40f8c6

Browse files
committed
Add a test for deprecation warnings
1 parent c810424 commit f40f8c6

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

tests/registry.rs

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,3 +1242,101 @@ fn bump_version_dont_update_registry() {
12421242
[FINISHED] [..]
12431243
"));
12441244
}
1245+
1246+
#[test]
1247+
fn old_version_req() {
1248+
let p = project("foo")
1249+
.file("Cargo.toml", r#"
1250+
[project]
1251+
name = "bar"
1252+
version = "0.5.0"
1253+
authors = []
1254+
1255+
[dependencies]
1256+
remote = "0.2*"
1257+
"#)
1258+
.file("src/main.rs", "fn main() {}");
1259+
p.build();
1260+
1261+
Package::new("remote", "0.2.0").publish();
1262+
1263+
assert_that(p.cargo("build"),
1264+
execs().with_status(0)
1265+
.with_stderr("\
1266+
warning: parsed version requirement `0.2*` is no longer valid
1267+
1268+
Previous versions of Cargo accepted this malformed requirement,
1269+
but it is being deprecated. This was found when parsing the manifest
1270+
of bar 0.5.0, and the correct version requirement is `0.2.*`.
1271+
1272+
This will soon become a hard error, so it's either recommended to
1273+
update to a fixed version or contact the upstream maintainer about
1274+
this warning.
1275+
1276+
warning: parsed version requirement `0.2*` is no longer valid
1277+
1278+
Previous versions of Cargo accepted this malformed requirement,
1279+
but it is being deprecated. This was found when parsing the manifest
1280+
of bar 0.5.0, and the correct version requirement is `0.2.*`.
1281+
1282+
This will soon become a hard error, so it's either recommended to
1283+
update to a fixed version or contact the upstream maintainer about
1284+
this warning.
1285+
1286+
[UPDATING] [..]
1287+
[DOWNLOADING] [..]
1288+
[COMPILING] [..]
1289+
[COMPILING] [..]
1290+
[FINISHED] [..]
1291+
"));
1292+
}
1293+
1294+
#[test]
1295+
fn old_version_req_upstream() {
1296+
let p = project("foo")
1297+
.file("Cargo.toml", r#"
1298+
[project]
1299+
name = "bar"
1300+
version = "0.5.0"
1301+
authors = []
1302+
1303+
[dependencies]
1304+
remote = "0.3"
1305+
"#)
1306+
.file("src/main.rs", "fn main() {}");
1307+
p.build();
1308+
1309+
Package::new("remote", "0.3.0")
1310+
.file("Cargo.toml", r#"
1311+
[project]
1312+
name = "remote"
1313+
version = "0.3.0"
1314+
authors = []
1315+
1316+
[dependencies]
1317+
bar = "0.2*"
1318+
"#)
1319+
.file("src/lib.rs", "")
1320+
.publish();
1321+
Package::new("bar", "0.2.0").publish();
1322+
1323+
assert_that(p.cargo("build"),
1324+
execs().with_status(0)
1325+
.with_stderr("\
1326+
[UPDATING] [..]
1327+
[DOWNLOADING] [..]
1328+
warning: parsed version requirement `0.2*` is no longer valid
1329+
1330+
Previous versions of Cargo accepted this malformed requirement,
1331+
but it is being deprecated. This was found when parsing the manifest
1332+
of remote 0.3.0, and the correct version requirement is `0.2.*`.
1333+
1334+
This will soon become a hard error, so it's either recommended to
1335+
update to a fixed version or contact the upstream maintainer about
1336+
this warning.
1337+
1338+
[COMPILING] [..]
1339+
[COMPILING] [..]
1340+
[FINISHED] [..]
1341+
"));
1342+
}

0 commit comments

Comments
 (0)