Skip to content

Commit

Permalink
Add tests for msrv check
Browse files Browse the repository at this point in the history
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
  • Loading branch information
Rustin170506 committed Dec 23, 2023
1 parent 0e42a8a commit dec9e8c
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit dec9e8c

Please sign in to comment.