From af9288f1b61ea3067770b031fced4d75a79e486c Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 17 Apr 2024 13:08:16 -0500 Subject: [PATCH] test(msrv): Show current parse behavior with X --- tests/testsuite/rust_version.rs | 102 ++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/tests/testsuite/rust_version.rs b/tests/testsuite/rust_version.rs index 01f49e32ff8..3df19e82406 100644 --- a/tests/testsuite/rust_version.rs +++ b/tests/testsuite/rust_version.rs @@ -124,6 +124,108 @@ fn rust_version_bad_pre_release() { .run(); } +#[cargo_test] +#[should_panic] +fn rust_version_x_wildcard() { + project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + edition = "2015" + authors = [] + rust-version = "x" + [[bin]] + name = "foo" + "#, + ) + .file("src/main.rs", "fn main() {}") + .build() + .cargo("check") + .with_status(101) + .with_stderr( + "\ +[ERROR] unexpected version requirement, expected a version like \"1.32\" + --> Cargo.toml:7:28 + | +7 | rust-version = \"^1.43\" + | ^^^^^^^ + | +", + ) + .run(); +} + +#[cargo_test] +#[should_panic] +fn rust_version_minor_x_wildcard() { + project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + edition = "2015" + authors = [] + rust-version = "1.x" + [[bin]] + name = "foo" + "#, + ) + .file("src/main.rs", "fn main() {}") + .build() + .cargo("check") + .with_status(101) + .with_stderr( + "\ +[ERROR] unexpected version requirement, expected a version like \"1.32\" + --> Cargo.toml:7:28 + | +7 | rust-version = \"1.x\" + | ^^^^^ + | +", + ) + .run(); +} + +#[cargo_test] +#[should_panic] +fn rust_version_patch_x_wildcard() { + project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.0.1" + edition = "2015" + authors = [] + rust-version = "1.30.x" + [[bin]] + name = "foo" + "#, + ) + .file("src/main.rs", "fn main() {}") + .build() + .cargo("check") + .with_status(101) + .with_stderr( + "\ +[ERROR] unexpected version requirement, expected a version like \"1.32\" + --> Cargo.toml:7:28 + | +7 | rust-version = \"1.30.x\" + | ^^^^^^^^ + | +", + ) + .run(); +} + #[cargo_test] fn rust_version_bad_nonsense() { project()