Skip to content

Commit

Permalink
Auto merge of #11011 - hi-rustin:rustin-patch-tests, r=epage
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Aug 22, 2022
2 parents 1ac83ba + 64e3991 commit fee1c7f
Showing 1 changed file with 73 additions and 1 deletion.
74 changes: 73 additions & 1 deletion tests/testsuite/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ fn change_package_version() {

#[cargo_test]
fn update_precise() {
Package::new("log", "0.1.0").publish();
Package::new("serde", "0.1.0").publish();
Package::new("serde", "0.2.1").publish();

Expand Down Expand Up @@ -392,6 +391,42 @@ fn update_precise() {
.run();
}

#[cargo_test]
fn update_precise_do_not_force_update_deps() {
Package::new("log", "0.1.0").publish();
Package::new("serde", "0.2.1").dep("log", "0.1").publish();

let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "bar"
version = "0.0.1"
authors = []
[dependencies]
serde = "0.2"
"#,
)
.file("src/lib.rs", "")
.build();

p.cargo("build").run();

Package::new("log", "0.1.1").publish();
Package::new("serde", "0.2.2").dep("log", "0.1").publish();

p.cargo("update -p serde:0.2.1 --precise 0.2.2")
.with_stderr(
"\
[UPDATING] `[..]` index
[UPDATING] serde v0.2.1 -> v0.2.2
",
)
.run();
}

#[cargo_test]
fn update_precise_without_package() {
Package::new("serde", "0.2.0").publish();
Expand Down Expand Up @@ -428,6 +463,43 @@ fn update_precise_without_package() {
.run();
}

#[cargo_test]
fn update_aggressive() {
Package::new("log", "0.1.0").publish();
Package::new("serde", "0.2.1").dep("log", "0.1").publish();

let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "bar"
version = "0.0.1"
authors = []
[dependencies]
serde = "0.2"
"#,
)
.file("src/lib.rs", "")
.build();

p.cargo("build").run();

Package::new("log", "0.1.1").publish();
Package::new("serde", "0.2.2").dep("log", "0.1").publish();

p.cargo("update -p serde:0.2.1 --aggressive")
.with_stderr(
"\
[UPDATING] `[..]` index
[UPDATING] log v0.1.0 -> v0.1.1
[UPDATING] serde v0.2.1 -> v0.2.2
",
)
.run();
}

#[cargo_test]
fn update_aggressive_without_package() {
Package::new("serde", "0.2.0").publish();
Expand Down

0 comments on commit fee1c7f

Please sign in to comment.