From d1375ba70efbe6aaea06e069a215fb0bed43f308 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 5 Dec 2024 15:20:55 -0600 Subject: [PATCH] test(rustflags): Put remap success test first --- tests/testsuite/rustflags.rs | 82 ++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/tests/testsuite/rustflags.rs b/tests/testsuite/rustflags.rs index 0d73f4b99..74fd2a195 100644 --- a/tests/testsuite/rustflags.rs +++ b/tests/testsuite/rustflags.rs @@ -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