test(rustflags): Put remap success test first

This commit is contained in:
Ed Page 2024-12-05 15:20:55 -06:00
parent 9e2c367300
commit d1375ba70e

View File

@ -1479,6 +1479,47 @@ fn env_rustflags_misspelled_build_script() {
.run();
}
#[cargo_test]
fn remap_path_prefix_works() {
// Check that remap-path-prefix works.
Package::new("bar", "0.1.0")
.file("src/lib.rs", "pub fn f() -> &'static str { file!() }")
.publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies]
bar = "0.1"
"#,
)
.file(
"src/main.rs",
r#"
fn main() {
println!("{}", bar::f());
}
"#,
)
.build();
p.cargo("run")
.env(
"RUSTFLAGS",
format!("--remap-path-prefix={}=/foo", paths::root().display()),
)
.with_stdout_data(str![[r#"
/foo/home/.cargo/registry/src/-[HASH]/bar-0.1.0/src/lib.rs
"#]])
.run();
}
#[cargo_test]
fn remap_path_prefix_ignored() {
let get_c_metadata_re =
@ -1521,47 +1562,6 @@ fn remap_path_prefix_ignored() {
assert_data_eq!(rustc_c_metadata, build_c_metadata);
}
#[cargo_test]
fn remap_path_prefix_works() {
// Check that remap-path-prefix works.
Package::new("bar", "0.1.0")
.file("src/lib.rs", "pub fn f() -> &'static str { file!() }")
.publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies]
bar = "0.1"
"#,
)
.file(
"src/main.rs",
r#"
fn main() {
println!("{}", bar::f());
}
"#,
)
.build();
p.cargo("run")
.env(
"RUSTFLAGS",
format!("--remap-path-prefix={}=/foo", paths::root().display()),
)
.with_stdout_data(str![[r#"
/foo/home/.cargo/registry/src/-[HASH]/bar-0.1.0/src/lib.rs
"#]])
.run();
}
#[cargo_test]
fn host_config_rustflags_with_target() {
// regression test for https://github.com/rust-lang/cargo/issues/10206