mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
Add testcase for custom build file warning
This commit is contained in:
parent
c5369e1459
commit
ac1e66d947
@ -439,7 +439,7 @@ fn warn_custom_build_file_not_in_package(
|
||||
"the source file of {:?} target `{}` doesn't appear to be a path inside of the package.\n\
|
||||
It is at {}, whereas the root the package is {}.\n\
|
||||
This may cause issue during packaging, as modules resolution and resources included via macros are often relative to the path of source files.\n\
|
||||
Please update the `build` setting in the manifest at `{}` and point to a path inside the root of the package.\n",
|
||||
Please update the `build` setting in the manifest at `{}` and point to a path inside the root of the package.",
|
||||
target.kind(), target.name(), path.display(), pkg.root().display(), pkg.manifest_path().display()
|
||||
);
|
||||
|
||||
|
@ -3304,3 +3304,57 @@ fn init_and_add_inner_target(p: ProjectBuilder) -> ProjectBuilder {
|
||||
.file("derp/target/foo.txt", "")
|
||||
.file("derp/not_target/foo.txt", "")
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn custom_build_warning() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
authors = []
|
||||
build = "../t_custom_build/custom_build.rs"
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.build();
|
||||
p.cargo("package -l")
|
||||
.with_stderr(format!(
|
||||
"\
|
||||
warning: manifest has no documentation, homepage or repository.
|
||||
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
|
||||
warning: build `{}/../t_custom_build/custom_build.rs` does not appear to exist.
|
||||
Please update the build setting in the manifest at `{}/Cargo.toml`
|
||||
This may become a hard error in the future.
|
||||
",
|
||||
p.root().display(),
|
||||
p.root().display()
|
||||
))
|
||||
.run();
|
||||
|
||||
// crate custom_build.rs outside the package root
|
||||
let custom_build_root = p.root().parent().unwrap().join("t_custom_build");
|
||||
_ = fs::create_dir(&custom_build_root).unwrap();
|
||||
_ = fs::write(&custom_build_root.join("custom_build.rs"), "fn main() {}");
|
||||
|
||||
p.cargo("package -l")
|
||||
.with_stderr(format!(
|
||||
"\
|
||||
warning: manifest has no documentation, homepage or repository.
|
||||
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
|
||||
warning: the source file of \"custom-build\" target `build-script-custom_build` doesn't appear to be a path inside of the package.
|
||||
It is at {}/t_custom_build/custom_build.rs, whereas the root the package is {}.
|
||||
This may cause issue during packaging, as modules resolution and resources included via macros are often relative to the path of source files.
|
||||
Please update the `build` setting in the manifest at `{}/Cargo.toml` and point to a path inside the root of the package.
|
||||
",
|
||||
p.root().parent().unwrap().display(),
|
||||
p.root().display(),
|
||||
p.root().display()
|
||||
))
|
||||
.run();
|
||||
_ = fs::remove_dir_all(&custom_build_root).unwrap();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user