@@ -3306,55 +3306,45 @@ fn init_and_add_inner_target(p: ProjectBuilder) -> ProjectBuilder {
3306
3306
}
3307
3307
3308
3308
#[ cargo_test]
3309
- fn custom_build_warning ( ) {
3309
+ fn build_script_outside_pkg_root ( ) {
3310
3310
let p = project ( )
3311
3311
. file (
3312
3312
"Cargo.toml" ,
3313
3313
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
+ "# ,
3322
3322
)
3323
3323
. file ( "src/main.rs" , "fn main() {}" )
3324
3324
. build ( ) ;
3325
- p. cargo ( "package -l" )
3326
- . with_stderr ( format ! (
3327
- "\
3325
+ let mut expect_msg = String :: from ( "\
3328
3326
warning: manifest has no documentation, homepage or repository.
3329
3327
See 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 ( ) ;
3338
3334
3339
- // crate custom_build.rs outside the package root
3335
+ // custom_build.rs outside the package root
3340
3336
let custom_build_root = p. root ( ) . parent ( ) . unwrap ( ) . join ( "t_custom_build" ) ;
3341
3337
_ = fs:: create_dir ( & custom_build_root) . unwrap ( ) ;
3342
3338
_ = 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
+ "\
3347
3341
warning: manifest has no documentation, homepage or repository.
3348
3342
See 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]` .
3351
3345
This 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 ( ) ;
3359
3349
_ = fs:: remove_dir_all ( & custom_build_root) . unwrap ( ) ;
3360
3350
}
0 commit comments