Skip to content

Commit 29b0817

Browse files
committed
Add test for dep within target having right path
1 parent 6ca27ff commit 29b0817

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/testsuite/dep_info.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,40 @@ fn build_dep_info_dylib() {
176176
assert!(p.example_lib("ex", "dylib").with_extension("d").is_file());
177177
}
178178

179+
#[cargo_test]
180+
fn dep_path_inside_target_has_correct_path() {
181+
let p = project()
182+
.file("Cargo.toml", &basic_bin_manifest("a"))
183+
.file("target/debug/blah", "")
184+
.file(
185+
"src/main.rs",
186+
r#"
187+
fn main() {
188+
let x = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/target/debug/blah"));
189+
}
190+
"#,
191+
)
192+
.build();
193+
194+
p.cargo("build").run();
195+
196+
let depinfo_path = &p.bin("a").with_extension("d");
197+
198+
assert!(depinfo_path.is_file(), "{:?}", depinfo_path);
199+
200+
let depinfo = p.read_file(depinfo_path.to_str().unwrap());
201+
202+
let bin_path = p.bin("a");
203+
if !depinfo.lines().any(|line| {
204+
line.starts_with(&format!("{}:", bin_path.display())) && line.contains("target/debug/blah")
205+
}) {
206+
panic!(
207+
"Could not find {:?}: target/debug/blah in {:?}",
208+
bin_path, depinfo_path
209+
);
210+
}
211+
}
212+
179213
#[cargo_test]
180214
fn no_rewrite_if_no_change() {
181215
let p = project().file("src/lib.rs", "").build();

0 commit comments

Comments
 (0)