mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
Add tests for msrv check
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
parent
0e42a8ae6d
commit
dec9e8cc1b
@ -5318,3 +5318,77 @@ for more information about build script outputs.
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn test_new_syntax_with_old_msrv() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.5.0"
|
||||
authors = []
|
||||
build = "build.rs"
|
||||
rust-version = "1.60.0"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file(
|
||||
"build.rs",
|
||||
r#"
|
||||
fn main() {
|
||||
println!("cargo::metadata=foo=bar");
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build")
|
||||
.with_status(101)
|
||||
.with_stderr_contains(
|
||||
"\
|
||||
[COMPILING] foo [..]
|
||||
error: the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, \
|
||||
but the minimum supported Rust version of `foo v0.5.0 ([ROOT]/foo)` is 1.60.0.
|
||||
See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \
|
||||
for more information about build script outputs.
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn test_old_syntax_with_old_msrv() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
build = "build.rs"
|
||||
rust-version = "1.60.0"
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"src/main.rs",
|
||||
r#"
|
||||
const FOO: &'static str = env!("FOO");
|
||||
fn main() {
|
||||
println!("{}", FOO);
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"build.rs",
|
||||
r#"fn main() {
|
||||
println!("cargo:rustc-env=FOO=foo");
|
||||
println!("cargo:foo=foo");
|
||||
}"#,
|
||||
)
|
||||
.build();
|
||||
p.cargo("build -v").run();
|
||||
p.cargo("run -v").with_stdout("foo\n").run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user