Skip to content

Commit

Permalink
test(resolver): Demonstrate existing behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Aug 25, 2023
1 parent f797978 commit 10196aa
Showing 1 changed file with 161 additions and 1 deletion.
162 changes: 161 additions & 1 deletion tests/testsuite/rust_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn rust_version_too_high() {
}

#[cargo_test]
fn rust_version_dependency_fails() {
fn dependency_rust_version_newer_than_rustc() {
Package::new("bar", "0.0.1")
.rust_version("1.2345.0")
.file("src/lib.rs", "fn other_stuff() {}")
Expand Down Expand Up @@ -189,6 +189,166 @@ fn rust_version_dependency_fails() {
p.cargo("check --ignore-rust-version").run();
}

#[cargo_test]
fn dependency_rust_version_newer_than_package() {
Package::new("bar", "1.6.0")
.rust_version("1.65.0")
.file("src/lib.rs", "fn other_stuff() {}")
.publish();

let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
rust-version = "1.60.0"
[dependencies]
bar = "1.0.0"
"#,
)
.file("src/main.rs", "fn main(){}")
.build();

p.cargo("check --ignore-rust-version")
.with_stderr(
"\
[UPDATING] `dummy-registry` index
[DOWNLOADING] crates ...
[DOWNLOADED] bar v1.6.0 (registry `dummy-registry`)
[CHECKING] bar v1.6.0
[CHECKING] [..]
[FINISHED] [..]
",
)
.run();
p.cargo("check")
.with_stderr(
"\
[FINISHED] [..]
",
)
.run();
}

#[cargo_test]
fn dependency_rust_version_older_and_newer_than_package() {
Package::new("bar", "1.5.0")
.rust_version("1.55.0")
.file("src/lib.rs", "fn other_stuff() {}")
.publish();
Package::new("bar", "1.6.0")
.rust_version("1.65.0")
.file("src/lib.rs", "fn other_stuff() {}")
.publish();

let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
rust-version = "1.60.0"
[dependencies]
bar = "1.0.0"
"#,
)
.file("src/main.rs", "fn main(){}")
.build();

p.cargo("check --ignore-rust-version")
.with_stderr(
"\
[UPDATING] `dummy-registry` index
[DOWNLOADING] crates ...
[DOWNLOADED] bar v1.6.0 (registry `dummy-registry`)
[CHECKING] bar v1.6.0
[CHECKING] [..]
[FINISHED] [..]
",
)
.run();
p.cargo("check")
.with_stderr(
"\
[FINISHED] [..]
",
)
.run();
}

#[cargo_test]
fn workspace_with_mixed_rust_version() {
Package::new("bar", "1.4.0")
.rust_version("1.45.0")
.file("src/lib.rs", "fn other_stuff() {}")
.publish();
Package::new("bar", "1.5.0")
.rust_version("1.55.0")
.file("src/lib.rs", "fn other_stuff() {}")
.publish();
Package::new("bar", "1.6.0")
.rust_version("1.65.0")
.file("src/lib.rs", "fn other_stuff() {}")
.publish();

let p = project()
.file(
"Cargo.toml",
r#"
[workspace]
members = ["lower"]
[package]
name = "higher"
version = "0.0.1"
authors = []
rust-version = "1.60.0"
[dependencies]
bar = "1.0.0"
"#,
)
.file("src/main.rs", "fn main() {}")
.file(
"lower/Cargo.toml",
r#"
[package]
name = "lower"
version = "0.0.1"
authors = []
rust-version = "1.50.0"
[dependencies]
bar = "1.0.0"
"#,
)
.file("lower/src/main.rs", "fn main() {}")
.build();

p.cargo("check --ignore-rust-version")
.with_stderr(
"\
[UPDATING] `dummy-registry` index
[DOWNLOADING] crates ...
[DOWNLOADED] bar v1.6.0 (registry `dummy-registry`)
[CHECKING] bar v1.6.0
[CHECKING] [..]
[FINISHED] [..]
",
)
.run();
p.cargo("check")
.with_stderr(
"\
[FINISHED] [..]
",
)
.run();
}

#[cargo_test]
fn rust_version_older_than_edition() {
project()
Expand Down

0 comments on commit 10196aa

Please sign in to comment.