Skip to content

Commit 2352cbd

Browse files
committed
add a test
1 parent c29e9ef commit 2352cbd

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/testsuite/update.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,59 @@ fn update_precise() {
391391
.run();
392392
}
393393

394+
#[cargo_test]
395+
fn update_precise_mismatched() {
396+
Package::new("serde", "1.2.0").publish();
397+
Package::new("serde", "1.2.1").publish();
398+
Package::new("serde", "1.6.0").publish();
399+
400+
let p = project()
401+
.file(
402+
"Cargo.toml",
403+
r#"
404+
[package]
405+
name = "bar"
406+
version = "0.0.1"
407+
authors = []
408+
409+
[dependencies]
410+
serde = "~1.2"
411+
"#,
412+
)
413+
.file("src/lib.rs", "")
414+
.build();
415+
416+
p.cargo("check").run();
417+
418+
// `1.6.0` does not match `"~1.2"`
419+
p.cargo("update serde:1.2 --precise 1.6.0")
420+
// This terrible error message was a regression in #12749
421+
.with_stderr(
422+
"\
423+
[UPDATING] `[..]` index
424+
thread 'main' panicked at src/cargo/util/semver_ext.rs:79:9:
425+
cannot update_precise ~1.2 to 1.6.0
426+
[..]
427+
",
428+
)
429+
.with_status(101)
430+
.run();
431+
432+
// `1.9.0` does not exist
433+
p.cargo("update serde:1.2 --precise 1.9.0")
434+
// This terrible error message has been the same for a long time. A fix is more than welcome!
435+
.with_stderr(
436+
"\
437+
[UPDATING] `[..]` index
438+
[ERROR] no matching package named `serde` found
439+
location searched: registry `crates-io`
440+
required by package `bar v0.0.1 ([..]/foo)`
441+
",
442+
)
443+
.with_status(101)
444+
.run();
445+
}
446+
394447
#[cargo_test]
395448
fn update_precise_build_metadata() {
396449
Package::new("serde", "0.0.1+first").publish();

0 commit comments

Comments
 (0)