@@ -1479,6 +1479,47 @@ fn env_rustflags_misspelled_build_script() {
14791479 . run ( ) ;
14801480}
14811481
1482+ #[ cargo_test]
1483+ fn remap_path_prefix_works ( ) {
1484+ // Check that remap-path-prefix works.
1485+ Package :: new ( "bar" , "0.1.0" )
1486+ . file ( "src/lib.rs" , "pub fn f() -> &'static str { file!() }" )
1487+ . publish ( ) ;
1488+
1489+ let p = project ( )
1490+ . file (
1491+ "Cargo.toml" ,
1492+ r#"
1493+ [package]
1494+ name = "foo"
1495+ version = "0.1.0"
1496+
1497+ [dependencies]
1498+ bar = "0.1"
1499+ "# ,
1500+ )
1501+ . file (
1502+ "src/main.rs" ,
1503+ r#"
1504+ fn main() {
1505+ println!("{}", bar::f());
1506+ }
1507+ "# ,
1508+ )
1509+ . build ( ) ;
1510+
1511+ p. cargo ( "run" )
1512+ . env (
1513+ "RUSTFLAGS" ,
1514+ format ! ( "--remap-path-prefix={}=/foo" , paths:: root( ) . display( ) ) ,
1515+ )
1516+ . with_stdout_data ( str![ [ r#"
1517+ /foo/home/.cargo/registry/src/-[HASH]/bar-0.1.0/src/lib.rs
1518+
1519+ "# ] ] )
1520+ . run ( ) ;
1521+ }
1522+
14821523#[ cargo_test]
14831524fn remap_path_prefix_ignored ( ) {
14841525 let get_c_metadata_re =
@@ -1521,47 +1562,6 @@ fn remap_path_prefix_ignored() {
15211562 assert_data_eq ! ( rustc_c_metadata, build_c_metadata) ;
15221563}
15231564
1524- #[ cargo_test]
1525- fn remap_path_prefix_works ( ) {
1526- // Check that remap-path-prefix works.
1527- Package :: new ( "bar" , "0.1.0" )
1528- . file ( "src/lib.rs" , "pub fn f() -> &'static str { file!() }" )
1529- . publish ( ) ;
1530-
1531- let p = project ( )
1532- . file (
1533- "Cargo.toml" ,
1534- r#"
1535- [package]
1536- name = "foo"
1537- version = "0.1.0"
1538-
1539- [dependencies]
1540- bar = "0.1"
1541- "# ,
1542- )
1543- . file (
1544- "src/main.rs" ,
1545- r#"
1546- fn main() {
1547- println!("{}", bar::f());
1548- }
1549- "# ,
1550- )
1551- . build ( ) ;
1552-
1553- p. cargo ( "run" )
1554- . env (
1555- "RUSTFLAGS" ,
1556- format ! ( "--remap-path-prefix={}=/foo" , paths:: root( ) . display( ) ) ,
1557- )
1558- . with_stdout_data ( str![ [ r#"
1559- /foo/home/.cargo/registry/src/-[HASH]/bar-0.1.0/src/lib.rs
1560-
1561- "# ] ] )
1562- . run ( ) ;
1563- }
1564-
15651565#[ cargo_test]
15661566fn host_config_rustflags_with_target ( ) {
15671567 // regression test for https://github.com/rust-lang/cargo/issues/10206
0 commit comments