@@ -3306,55 +3306,45 @@ fn init_and_add_inner_target(p: ProjectBuilder) -> ProjectBuilder {
33063306}
33073307
33083308#[ cargo_test]
3309- fn custom_build_warning ( ) {
3309+ fn build_script_outside_pkg_root ( ) {
33103310 let p = project ( )
33113311 . file (
33123312 "Cargo.toml" ,
33133313 r#"
3314- [package]
3315- name = "foo"
3316- version = "0.0.1"
3317- license = "MIT"
3318- description = "foo"
3319- authors = []
3320- build = "../t_custom_build/custom_build.rs"
3321- "# ,
3314+ [package]
3315+ name = "foo"
3316+ version = "0.0.1"
3317+ license = "MIT"
3318+ description = "foo"
3319+ authors = []
3320+ build = "../t_custom_build/custom_build.rs"
3321+ "# ,
33223322 )
33233323 . file ( "src/main.rs" , "fn main() {}" )
33243324 . build ( ) ;
3325- p. cargo ( "package -l" )
3326- . with_stderr ( format ! (
3327- "\
3325+ let mut expect_msg = String :: from ( "\
33283326 warning: manifest has no documentation, homepage or repository.
33293327See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
3330- warning: build `{}/../t_custom_build/custom_build.rs` does not appear to exist.
3331- Please update the build setting in the manifest at `{}/Cargo.toml`
3332- This may become a hard error in the future.
3333- " ,
3334- p. root( ) . display( ) ,
3335- p. root( ) . display( )
3336- ) )
3337- . run ( ) ;
3328+ error: the source file of \" custom-build\" target `build-script-custom_build` doesn't appear to exist.
3329+ This may cause issue during packaging, as modules resolution and resources included via macros are often relative to the path of source files.
3330+ Please update the `build` setting in the manifest at `[CWD]/Cargo.toml` and point to a path inside the root of the package.
3331+ " ) ;
3332+ // custom_build.rs does not exist
3333+ p. cargo ( "package -l" ) . with_stderr ( & expect_msg) . run ( ) ;
33383334
3339- // crate custom_build.rs outside the package root
3335+ // custom_build.rs outside the package root
33403336 let custom_build_root = p. root ( ) . parent ( ) . unwrap ( ) . join ( "t_custom_build" ) ;
33413337 _ = fs:: create_dir ( & custom_build_root) . unwrap ( ) ;
33423338 _ = fs:: write ( & custom_build_root. join ( "custom_build.rs" ) , "fn main() {}" ) ;
3343-
3344- p. cargo ( "package -l" )
3345- . with_stderr ( format ! (
3346- "\
3339+ expect_msg = format ! (
3340+ "\
33473341 warning: manifest has no documentation, homepage or repository.
33483342See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
3349- warning : the source file of \" custom-build\" target `build-script-custom_build` doesn't appear to be a path inside of the package.
3350- It is at {}/t_custom_build/custom_build.rs, whereas the root the package is {} .
3343+ error : the source file of \" custom-build\" target `build-script-custom_build` doesn't appear to be a path inside of the package.
3344+ It is at ` {}/t_custom_build/custom_build.rs` , whereas the root the package is `[CWD]` .
33513345This may cause issue during packaging, as modules resolution and resources included via macros are often relative to the path of source files.
3352- Please update the `build` setting in the manifest at `{}/Cargo.toml` and point to a path inside the root of the package.
3353- " ,
3354- p. root( ) . parent( ) . unwrap( ) . display( ) ,
3355- p. root( ) . display( ) ,
3356- p. root( ) . display( )
3357- ) )
3358- . run ( ) ;
3346+ Please update the `build` setting in the manifest at `[CWD]/Cargo.toml` and point to a path inside the root of the package.
3347+ " , p. root( ) . parent( ) . unwrap( ) . display( ) ) ;
3348+ p. cargo ( "package -l" ) . with_stderr ( & expect_msg) . run ( ) ;
33593349 _ = fs:: remove_dir_all ( & custom_build_root) . unwrap ( ) ;
33603350}
0 commit comments