Skip to content

Commit e619bf0

Browse files
committed
test(update): Show current behavior for --breaking with non-existent packages
This test demonstrates the current behavior where invalid package specifications passed to `cargo update --breaking` are silently ignored instead of reporting an error. The test shows three scenarios: 1. Non-existent package produces no output (silently ignored) 2. Mix of valid and invalid packages processes only the valid one 3. Transitive dependencies produce no output (silently ignored) A subsequent commit will fix this behavior and update these tests to verify proper error reporting for non-existent and non-upgradeable packages.
1 parent 19678fc commit e619bf0

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

tests/testsuite/update.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,3 +2750,66 @@ Caused by:
27502750
"#]])
27512751
.run();
27522752
}
2753+
2754+
#[cargo_test]
2755+
fn update_breaking_missing_package_error() {
2756+
Package::new("bar", "1.0.0").publish();
2757+
Package::new("transitive", "1.0.0").publish();
2758+
2759+
let p = project()
2760+
.file(
2761+
"Cargo.toml",
2762+
r#"
2763+
[package]
2764+
name = "foo"
2765+
version = "0.0.1"
2766+
edition = "2015"
2767+
authors = []
2768+
2769+
[dependencies]
2770+
bar = "1.0"
2771+
"#,
2772+
)
2773+
.file("src/lib.rs", "")
2774+
.build();
2775+
2776+
p.cargo("generate-lockfile").run();
2777+
2778+
Package::new("bar", "2.0.0")
2779+
.add_dep(Dependency::new("transitive", "1.0.0").build())
2780+
.publish();
2781+
2782+
// This test demonstrates the current buggy behavior where invalid package
2783+
// specs are silently ignored instead of reporting an error. A subsequent
2784+
// commit will fix this behavior and update this test to verify proper
2785+
// error reporting.
2786+
2787+
// Non-existent package is silently ignored
2788+
p.cargo("update -Zunstable-options --breaking no_such_crate")
2789+
.masquerade_as_nightly_cargo(&["update-breaking"])
2790+
.with_stderr_data(str![[r#"
2791+
2792+
"#]])
2793+
.run();
2794+
2795+
// Valid package processes, invalid package silently ignored
2796+
p.cargo("update -Zunstable-options --breaking bar no_such_crate")
2797+
.masquerade_as_nightly_cargo(&["update-breaking"])
2798+
.with_stderr_data(str![[r#"
2799+
[UPDATING] `dummy-registry` index
2800+
[UPGRADING] bar ^1.0 -> ^2.0
2801+
[LOCKING] 2 packages to latest compatible versions
2802+
[UPDATING] bar v1.0.0 -> v2.0.0
2803+
[ADDING] transitive v1.0.0
2804+
2805+
"#]])
2806+
.run();
2807+
2808+
// Transitive dependency is silently ignored (produces no output)
2809+
p.cargo("update -Zunstable-options --breaking transitive")
2810+
.masquerade_as_nightly_cargo(&["update-breaking"])
2811+
.with_stderr_data(str![[r#"
2812+
2813+
"#]])
2814+
.run();
2815+
}

0 commit comments

Comments
 (0)