Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Oct 25, 2023
1 parent 539068b commit f7aed16
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/testsuite/profile_trim_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,60 @@ warning: unused variable: `unused`
)
.run();
}

#[cfg(target_os = "linux")]
#[cargo_test(requires_strings, nightly, reason = "-Zremap-path-scope is unstable")]
fn registry_dependency() {
Package::new("bar", "0.0.1")
.file("Cargo.toml", &basic_manifest("bar", "0.0.1"))
.file("src/lib.rs", r#"pub fn f() { println!("{}", file!()); }"#)
.publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
[dependencies]
bar = "0.0.1"
[profile.dev]
trim-paths = "object"
"#,
)
.file("src/main.rs", "fn main() { bar::f(); }")
.build();

let registry_src = paths::home().join(".cargo/registry/src");
let pkg_remap = format!("{}/[..]/bar-0.0.1=bar-0.0.1", registry_src.display());

p.cargo("build --verbose -Ztrim-paths")
.masquerade_as_nightly_cargo(&["-Ztrim-paths"])
.with_stdout("bar-0.0.1/src/lib.rs")
.with_stderr(&format!(
"\
[UPDATING] [..]
[DOWNLOADING] crates ...
[DOWNLOADED] bar v0.0.1 ([..])
[COMPILING] bar v0.0.1
[RUNNING] `rustc [..]\
-Zremap-path-scope=object \
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
--remap-path-prefix={pkg_remap} [..]
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc [..]\
-Zremap-path-scope=object \
--remap-path-prefix=[..]/lib/rustlib/src/rust=/rustc/[..] \
--remap-path-prefix=[CWD]= [..]
[FINISHED] dev [..]",
))
.run();

let executable = p.bin("foo");
assert!(executable.is_file());

std::process::Command::new("strings")

}

0 comments on commit f7aed16

Please sign in to comment.