Skip to content

Commit d4f36b2

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 covers: 1. Non-existent packages are silently ignored 2. Mix of valid and invalid packages processes only valid ones 3. Transitive dependencies are silently ignored 4. Renamed, non-semver, no-breaking-update dependencies are silently ignored Split the existing test into separate cases for transitive vs renamed/non-semver/no-breaking-update dependencies. A subsequent commit will fix this behavior and update these tests to verify proper error reporting. Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
1 parent 23f5b2b commit d4f36b2

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

tests/testsuite/update.rs

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2161,7 +2161,16 @@ fn update_breaking_specific_packages_that_wont_update() {
21612161
Package::new("non-semver", "2.0.0").publish();
21622162
Package::new("transitive-incompatible", "2.0.0").publish();
21632163

2164-
p.cargo("update -Zunstable-options --breaking compatible renamed-from non-semver transitive-compatible transitive-incompatible")
2164+
// Transitive dependencies are silently ignored
2165+
p.cargo("update -Zunstable-options --breaking transitive-compatible transitive-incompatible")
2166+
.masquerade_as_nightly_cargo(&["update-breaking"])
2167+
.with_stderr_data(str![[r#"
2168+
2169+
"#]])
2170+
.run();
2171+
2172+
// Renamed, non-semver, no-breaking-update dependencies are silently ignored
2173+
p.cargo("update -Zunstable-options --breaking compatible renamed-from non-semver")
21652174
.masquerade_as_nightly_cargo(&["update-breaking"])
21662175
.with_stderr_data(str![[r#"
21672176
[UPDATING] `[..]` index
@@ -2750,3 +2759,66 @@ Caused by:
27502759
"#]])
27512760
.run();
27522761
}
2762+
2763+
#[cargo_test]
2764+
fn update_breaking_missing_package_error() {
2765+
Package::new("bar", "1.0.0").publish();
2766+
Package::new("transitive", "1.0.0").publish();
2767+
2768+
let p = project()
2769+
.file(
2770+
"Cargo.toml",
2771+
r#"
2772+
[package]
2773+
name = "foo"
2774+
version = "0.0.1"
2775+
edition = "2015"
2776+
authors = []
2777+
2778+
[dependencies]
2779+
bar = "1.0"
2780+
"#,
2781+
)
2782+
.file("src/lib.rs", "")
2783+
.build();
2784+
2785+
p.cargo("generate-lockfile").run();
2786+
2787+
Package::new("bar", "2.0.0")
2788+
.add_dep(Dependency::new("transitive", "1.0.0").build())
2789+
.publish();
2790+
2791+
// This test demonstrates the current buggy behavior where invalid package
2792+
// specs are silently ignored instead of reporting an error. A subsequent
2793+
// commit will fix this behavior and update this test to verify proper
2794+
// error reporting.
2795+
2796+
// Non-existent package is silently ignored
2797+
p.cargo("update -Zunstable-options --breaking no_such_crate")
2798+
.masquerade_as_nightly_cargo(&["update-breaking"])
2799+
.with_stderr_data(str![[r#"
2800+
2801+
"#]])
2802+
.run();
2803+
2804+
// Valid package processes, invalid package silently ignored
2805+
p.cargo("update -Zunstable-options --breaking bar no_such_crate")
2806+
.masquerade_as_nightly_cargo(&["update-breaking"])
2807+
.with_stderr_data(str![[r#"
2808+
[UPDATING] `dummy-registry` index
2809+
[UPGRADING] bar ^1.0 -> ^2.0
2810+
[LOCKING] 2 packages to latest compatible versions
2811+
[UPDATING] bar v1.0.0 -> v2.0.0
2812+
[ADDING] transitive v1.0.0
2813+
2814+
"#]])
2815+
.run();
2816+
2817+
// Transitive dependency is silently ignored (produces no output)
2818+
p.cargo("update -Zunstable-options --breaking transitive")
2819+
.masquerade_as_nightly_cargo(&["update-breaking"])
2820+
.with_stderr_data(str![[r#"
2821+
2822+
"#]])
2823+
.run();
2824+
}

0 commit comments

Comments
 (0)