@@ -3306,55 +3306,46 @@ 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 =
3326+ String :: from ( "\
33283327 warning: manifest has no documentation, homepage or repository.
33293328See 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 ( ) ;
3329+ error: the source file of \" custom-build\" target `build-script-custom_build` doesn't appear to exist.
3330+ This may cause issue during packaging, as modules resolution and resources included via macros are often relative to the path of source files.
3331+ Please update the `build` setting in the manifest at `[CWD]/Cargo.toml` and point to a path inside the root of the package.
3332+ " ) ;
3333+ // custom_build.rs does not exist
3334+ p. cargo ( "package -l" ) . with_stderr ( & expect_msg) . run ( ) ;
33383335
3339- // crate custom_build.rs outside the package root
3336+ // custom_build.rs outside the package root
33403337 let custom_build_root = p. root ( ) . parent ( ) . unwrap ( ) . join ( "t_custom_build" ) ;
33413338 _ = fs:: create_dir ( & custom_build_root) . unwrap ( ) ;
33423339 _ = fs:: write ( & custom_build_root. join ( "custom_build.rs" ) , "fn main() {}" ) ;
3343-
3344- p. cargo ( "package -l" )
3345- . with_stderr ( format ! (
3346- "\
3340+ expect_msg = format ! (
3341+ "\
33473342 warning: manifest has no documentation, homepage or repository.
33483343See 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 {} .
3344+ error : the source file of \" custom-build\" target `build-script-custom_build` doesn't appear to be a path inside of the package.
3345+ It is at ` {}/t_custom_build/custom_build.rs` , whereas the root the package is `[CWD]` .
33513346This 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 ( ) ;
3347+ Please update the `build` setting in the manifest at `[CWD]/Cargo.toml` and point to a path inside the root of the package.
3348+ " , p. root( ) . parent( ) . unwrap( ) . display( ) ) ;
3349+ p. cargo ( "package -l" ) . with_stderr ( & expect_msg) . run ( ) ;
33593350 _ = fs:: remove_dir_all ( & custom_build_root) . unwrap ( ) ;
33603351}
0 commit comments