mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
test(trim-paths): not remapped in build script gen'd code
This was discovered in <https://github.com/rust-lang/rust/issues/111540#issuecomment-2544049895>. Co-authored-by: Urgau <urgau@numericable.fr>
This commit is contained in:
parent
56a1118e52
commit
463e9ed3cd
@ -246,6 +246,78 @@ fn registry_dependency() {
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test(nightly, reason = "-Zremap-path-scope is unstable")]
|
||||
fn registry_dependency_with_build_script_codegen() {
|
||||
Package::new("bar", "0.0.1")
|
||||
.file("Cargo.toml", &basic_manifest("bar", "0.0.1"))
|
||||
.file(
|
||||
"build.rs",
|
||||
r#"
|
||||
fn main() {
|
||||
let out_dir = std::env::var("OUT_DIR").unwrap();
|
||||
let dest = std::path::PathBuf::from(out_dir);
|
||||
std::fs::write(
|
||||
dest.join("bindings.rs"),
|
||||
"pub fn my_file() -> &'static str { file!() }",
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
r#"
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
"#,
|
||||
)
|
||||
.publish();
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
|
||||
[dependencies]
|
||||
bar = "0.0.1"
|
||||
|
||||
[profile.dev]
|
||||
trim-paths = "object"
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"src/main.rs",
|
||||
r#"fn main() { println!("{}", bar::my_file()); }"#,
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("run --verbose -Ztrim-paths")
|
||||
.masquerade_as_nightly_cargo(&["-Ztrim-paths"])
|
||||
// Macros should be sanitized
|
||||
.with_stdout_data(str![[r#"
|
||||
[ROOT]/foo/target/debug/build/bar-[HASH]/out/bindings.rs
|
||||
|
||||
"#]]) // Omit the hash of Source URL
|
||||
.with_stderr_data(str![[r#"
|
||||
[UPDATING] `dummy-registry` index
|
||||
[LOCKING] 1 package to latest compatible version
|
||||
[DOWNLOADING] crates ...
|
||||
[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`)
|
||||
[COMPILING] bar v0.0.1
|
||||
[RUNNING] `rustc --crate-name build_script_build [..]-Zremap-path-scope=object --remap-path-prefix=[ROOT]/home/.cargo/registry/src= --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]`
|
||||
[RUNNING] `[ROOT]/foo/target/debug/build/bar-[HASH]/build-script-build`
|
||||
[RUNNING] `rustc --crate-name bar [..]-Zremap-path-scope=object --remap-path-prefix=[ROOT]/home/.cargo/registry/src= --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]`
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc --crate-name foo [..]-Zremap-path-scope=object --remap-path-prefix=[ROOT]/foo=. --remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..]`
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[RUNNING] `target/debug/foo[EXE]`
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test(nightly, reason = "-Zremap-path-scope is unstable")]
|
||||
fn git_dependency() {
|
||||
let git_project = git::new("bar", |project| {
|
||||
|
Loading…
x
Reference in New Issue
Block a user