add a test

This commit is contained in:
Jacob Finkelman 2023-11-06 19:57:58 +00:00
parent c29e9efccb
commit 2352cbd1f9

View File

@ -391,6 +391,59 @@ fn update_precise() {
.run();
}
#[cargo_test]
fn update_precise_mismatched() {
Package::new("serde", "1.2.0").publish();
Package::new("serde", "1.2.1").publish();
Package::new("serde", "1.6.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "bar"
version = "0.0.1"
authors = []
[dependencies]
serde = "~1.2"
"#,
)
.file("src/lib.rs", "")
.build();
p.cargo("check").run();
// `1.6.0` does not match `"~1.2"`
p.cargo("update serde:1.2 --precise 1.6.0")
// This terrible error message was a regression in #12749
.with_stderr(
"\
[UPDATING] `[..]` index
thread 'main' panicked at src/cargo/util/semver_ext.rs:79:9:
cannot update_precise ~1.2 to 1.6.0
[..]
",
)
.with_status(101)
.run();
// `1.9.0` does not exist
p.cargo("update serde:1.2 --precise 1.9.0")
// This terrible error message has been the same for a long time. A fix is more than welcome!
.with_stderr(
"\
[UPDATING] `[..]` index
[ERROR] no matching package named `serde` found
location searched: registry `crates-io`
required by package `bar v0.0.1 ([..]/foo)`
",
)
.with_status(101)
.run();
}
#[cargo_test]
fn update_precise_build_metadata() {
Package::new("serde", "0.0.1+first").publish();