Skip to content

Commit b4ad206

Browse files
committed
test(update): Show behavior for missing feature
1 parent c75feb9 commit b4ad206

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/testsuite/update.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,3 +1536,48 @@ fn report_behind() {
15361536
)
15371537
.run();
15381538
}
1539+
1540+
#[cargo_test]
1541+
fn update_with_missing_feature() {
1542+
// Attempting to update a package to a version with a missing feature
1543+
// should produce a warning.
1544+
Package::new("bar", "0.1.0").feature("feat1", &[]).publish();
1545+
1546+
let p = project()
1547+
.file(
1548+
"Cargo.toml",
1549+
r#"
1550+
[package]
1551+
name = "foo"
1552+
version = "0.1.0"
1553+
1554+
[dependencies]
1555+
bar = {version="0.1", features=["feat1"]}
1556+
"#,
1557+
)
1558+
.file("src/lib.rs", "")
1559+
.build();
1560+
p.cargo("generate-lockfile").run();
1561+
1562+
// Publish an update that is missing the feature.
1563+
Package::new("bar", "0.1.1").publish();
1564+
1565+
p.cargo("update")
1566+
.with_stderr(
1567+
"\
1568+
[UPDATING] `[..]` index
1569+
",
1570+
)
1571+
.run();
1572+
1573+
// Publish a fixed version, should not warn.
1574+
Package::new("bar", "0.1.2").feature("feat1", &[]).publish();
1575+
p.cargo("update")
1576+
.with_stderr(
1577+
"\
1578+
[UPDATING] `[..]` index
1579+
[UPDATING] bar v0.1.0 -> v0.1.2
1580+
",
1581+
)
1582+
.run();
1583+
}

0 commit comments

Comments
 (0)