Skip to content

Commit 68f606c

Browse files
committed
test: update_precise_breaking_direct_plus_transitive
1 parent 0fe5f00 commit 68f606c

File tree

2 files changed

+67
-4
lines changed

2 files changed

+67
-4
lines changed

src/cargo/ops/cargo_update.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,13 @@ pub fn update_lockfile(
109109
};
110110
let mut registry = ws.package_registry()?;
111111
let mut to_avoid = HashSet::new();
112+
let breaking_update = !upgrades.is_empty();
112113

113-
if opts.breaking {
114+
if breaking_update {
114115
// We don't necessarily want to update all specified packages. If we are
115-
// doing a breaking update (or precise upgrades, coming in #14140), we
116-
// don't want to touch any packages that have no breaking updates. So we
117-
// want to only avoid all packages that got upgraded.
116+
// doing a breaking update or precise upgrade, we don't want to touch
117+
// any packages that have no breaking updates. So we want to only avoid
118+
// all packages that got upgraded.
118119

119120
for name in opts.to_update.iter() {
120121
// We still want to query any specified package, for the sake of

tests/testsuite/update.rs

+62
Original file line numberDiff line numberDiff line change
@@ -2564,6 +2564,68 @@ perhaps a crate was updated and forgotten to be re-vendored?
25642564
.run();
25652565
}
25662566

2567+
#[cargo_test]
2568+
fn update_precise_breaking_direct_plus_transitive() {
2569+
Package::new("incompatible", "1.0.0").publish();
2570+
2571+
let p = project()
2572+
.file(
2573+
"Cargo.toml",
2574+
r#"
2575+
# Check if formatting is preserved
2576+
2577+
[package]
2578+
name = "foo"
2579+
version = "0.0.1"
2580+
edition = "2015"
2581+
authors = []
2582+
2583+
[dependencies]
2584+
incompatible = "1.0" # Comment
2585+
bar = { path = "bar" }
2586+
"#,
2587+
)
2588+
.file("src/lib.rs", "")
2589+
.file(
2590+
"bar/Cargo.toml",
2591+
r#"
2592+
[package]
2593+
name = "bar"
2594+
version = "0.0.1"
2595+
edition = "2015"
2596+
authors = []
2597+
2598+
[dependencies]
2599+
incompatible = "1.0"
2600+
"#,
2601+
)
2602+
.file("bar/src/lib.rs", "")
2603+
.build();
2604+
2605+
p.cargo("generate-lockfile").run();
2606+
let lock1 = p.read_lockfile();
2607+
2608+
Package::new("incompatible", "2.0.0").publish();
2609+
Package::new("incompatible", "2.0.1").publish();
2610+
2611+
p.cargo("update -Zunstable-options incompatible --precise 2.0.0")
2612+
.masquerade_as_nightly_cargo(&["update-precise-breaking"])
2613+
.with_stderr_data(str![[r#"
2614+
[UPGRADING] incompatible ^1.0 -> ^2.0
2615+
[UPDATING] `dummy-registry` index
2616+
[ADDING] incompatible v2.0.0 (latest: v2.0.1)
2617+
[NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest
2618+
2619+
"#]])
2620+
.run();
2621+
2622+
let lock2 = p.read_lockfile();
2623+
2624+
assert_ne!(lock1, lock2);
2625+
assert!(lock2.contains("incompatible 1.0.0"));
2626+
assert!(lock2.contains("incompatible 2.0.0"));
2627+
}
2628+
25672629
#[cargo_test]
25682630
fn update_precise_breaking_incompatible_downgrade() {
25692631
Package::new("incompatible", "1.0.0").publish();

0 commit comments

Comments
 (0)