Skip to content

Commit fee1c7f

Browse files
committed
Auto merge of #11011 - hi-rustin:rustin-patch-tests, r=epage
Add more tests for aggressive or precise update ### What does this PR try to resolve? When I was working on #10988, I found there is no test for the aggressive update. So I added it. Also, I added a test for precise update to make sure it won't force update the deps of SPEC. ### How should we test and review this PR? Unit tests.
2 parents 1ac83ba + 64e3991 commit fee1c7f

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
@@ -344,7 +344,6 @@ fn change_package_version() {
344344

345345
#[cargo_test]
346346
fn update_precise() {
347-
Package::new("log", "0.1.0").publish();
348347
Package::new("serde", "0.1.0").publish();
349348
Package::new("serde", "0.2.1").publish();
350349

@@ -392,6 +391,42 @@ fn update_precise() {
392391
.run();
393392
}
394393

394+
#[cargo_test]
395+
fn update_precise_do_not_force_update_deps() {
396+
Package::new("log", "0.1.0").publish();
397+
Package::new("serde", "0.2.1").dep("log", "0.1").publish();
398+
399+
let p = project()
400+
.file(
401+
"Cargo.toml",
402+
r#"
403+
[package]
404+
name = "bar"
405+
version = "0.0.1"
406+
authors = []
407+
408+
[dependencies]
409+
serde = "0.2"
410+
"#,
411+
)
412+
.file("src/lib.rs", "")
413+
.build();
414+
415+
p.cargo("build").run();
416+
417+
Package::new("log", "0.1.1").publish();
418+
Package::new("serde", "0.2.2").dep("log", "0.1").publish();
419+
420+
p.cargo("update -p serde:0.2.1 --precise 0.2.2")
421+
.with_stderr(
422+
"\
423+
[UPDATING] `[..]` index
424+
[UPDATING] serde v0.2.1 -> v0.2.2
425+
",
426+
)
427+
.run();
428+
}
429+
395430
#[cargo_test]
396431
fn update_precise_without_package() {
397432
Package::new("serde", "0.2.0").publish();
@@ -428,6 +463,43 @@ fn update_precise_without_package() {
428463
.run();
429464
}
430465

466+
#[cargo_test]
467+
fn update_aggressive() {
468+
Package::new("log", "0.1.0").publish();
469+
Package::new("serde", "0.2.1").dep("log", "0.1").publish();
470+
471+
let p = project()
472+
.file(
473+
"Cargo.toml",
474+
r#"
475+
[package]
476+
name = "bar"
477+
version = "0.0.1"
478+
authors = []
479+
480+
[dependencies]
481+
serde = "0.2"
482+
"#,
483+
)
484+
.file("src/lib.rs", "")
485+
.build();
486+
487+
p.cargo("build").run();
488+
489+
Package::new("log", "0.1.1").publish();
490+
Package::new("serde", "0.2.2").dep("log", "0.1").publish();
491+
492+
p.cargo("update -p serde:0.2.1 --aggressive")
493+
.with_stderr(
494+
"\
495+
[UPDATING] `[..]` index
496+
[UPDATING] log v0.1.0 -> v0.1.1
497+
[UPDATING] serde v0.2.1 -> v0.2.2
498+
",
499+
)
500+
.run();
501+
}
502+
431503
#[cargo_test]
432504
fn update_aggressive_without_package() {
433505
Package::new("serde", "0.2.0").publish();

0 commit comments

Comments
 (0)