diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /src/tools/cargo/tests/testsuite/rust_version.rs | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/tests/testsuite/rust_version.rs')
-rw-r--r-- | src/tools/cargo/tests/testsuite/rust_version.rs | 253 |
1 files changed, 245 insertions, 8 deletions
diff --git a/src/tools/cargo/tests/testsuite/rust_version.rs b/src/tools/cargo/tests/testsuite/rust_version.rs index 91711cf1a..21321b7c5 100644 --- a/src/tools/cargo/tests/testsuite/rust_version.rs +++ b/src/tools/cargo/tests/testsuite/rust_version.rs @@ -44,8 +44,48 @@ fn rust_version_bad_caret() { .cargo("check") .with_status(101) .with_stderr( - "error: failed to parse manifest at `[..]`\n\n\ - Caused by:\n `rust-version` must be a value like \"1.32\"", + "\ +error: failed to parse manifest at `[..]` + +Caused by: + TOML parse error at line 6, column 28 + | + 6 | rust-version = \"^1.43\" + | ^^^^^^^ + unexpected version requirement, expected a version like \"1.32\"", + ) + .run(); +} + +#[cargo_test] +fn rust_version_good_pre_release() { + project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + rust-version = "1.43.0-beta.1" + [[bin]] + name = "foo" + "#, + ) + .file("src/main.rs", "fn main() {}") + .build() + .cargo("check") + .with_status(101) + .with_stderr( + "\ +error: failed to parse manifest at `[..]` + +Caused by: + TOML parse error at line 6, column 28 + | + 6 | rust-version = \"1.43.0-beta.1\" + | ^^^^^^^^^^^^^^^ + unexpected prerelease field, expected a version like \"1.32\"", ) .run(); } @@ -70,8 +110,15 @@ fn rust_version_bad_pre_release() { .cargo("check") .with_status(101) .with_stderr( - "error: failed to parse manifest at `[..]`\n\n\ - Caused by:\n `rust-version` must be a value like \"1.32\"", + "\ +error: failed to parse manifest at `[..]` + +Caused by: + TOML parse error at line 6, column 28 + | + 6 | rust-version = \"1.43-beta.1\" + | ^^^^^^^^^^^^^ + unexpected prerelease field, expected a version like \"1.32\"", ) .run(); } @@ -96,8 +143,15 @@ fn rust_version_bad_nonsense() { .cargo("check") .with_status(101) .with_stderr( - "error: failed to parse manifest at `[..]`\n\n\ - Caused by:\n `rust-version` must be a value like \"1.32\"", + "\ +error: failed to parse manifest at `[..]` + +Caused by: + TOML parse error at line 6, column 28 + | + 6 | rust-version = \"foodaddle\" + | ^^^^^^^^^^^ + expected a version like \"1.32\"", ) .run(); } @@ -131,7 +185,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() {}") @@ -161,7 +215,7 @@ fn rust_version_dependency_fails() { error: package `bar v0.0.1` cannot be built because it requires \ rustc 1.2345.0 or newer, while the currently active rustc version is [..]\n\ Either upgrade to rustc 1.2345.0 or newer, or use\n\ - cargo update -p bar@0.0.1 --precise ver\n\ + cargo update bar@0.0.1 --precise ver\n\ where `ver` is the latest version of `bar` supporting rustc [..]", ) .run(); @@ -169,6 +223,189 @@ fn rust_version_dependency_fails() { } #[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") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + // This shouldn't fail + .with_status(101) + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[ERROR] failed to select a version for the requirement `bar = \"^1.0.0\"` +candidate versions found which didn't match: 1.6.0 +location searched: `dummy-registry` index (which is replacing registry `crates-io`) +required by package `foo v0.0.1 ([CWD])` +perhaps a crate was updated and forgotten to be re-vendored? +", + ) + .run(); + p.cargo("check") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + .with_status(101) + // This should have a better error message + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[ERROR] failed to select a version for the requirement `bar = \"^1.0.0\"` +candidate versions found which didn't match: 1.6.0 +location searched: `dummy-registry` index (which is replacing registry `crates-io`) +required by package `foo v0.0.1 ([CWD])` +perhaps a crate was updated and forgotten to be re-vendored? +", + ) + .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") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + // This should pick 1.6.0 + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[DOWNLOADING] crates ... +[DOWNLOADED] bar v1.5.0 (registry `dummy-registry`) +[CHECKING] bar v1.5.0 +[CHECKING] [..] +[FINISHED] [..] +", + ) + .run(); + p.cargo("check") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + .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") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + // This should pick 1.6.0 + .with_stderr( + "\ +[UPDATING] `dummy-registry` index +[DOWNLOADING] crates ... +[DOWNLOADED] bar v1.4.0 (registry `dummy-registry`) +[CHECKING] bar v1.4.0 +[CHECKING] [..] +[FINISHED] [..] +", + ) + .run(); + p.cargo("check") + .arg("-Zmsrv-policy") + .masquerade_as_nightly_cargo(&["msrv-policy"]) + .with_stderr( + "\ +[FINISHED] [..] +", + ) + .run(); +} + +#[cargo_test] fn rust_version_older_than_edition() { project() .file( |