Skip to content

Commit e83f8dd

Browse files
committed
test(depinfo): add trailing separator test showcasing unintended trailing path separator
1 parent df07b39 commit e83f8dd

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

tests/testsuite/dep_info.rs

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,3 +552,103 @@ fn non_local_build_script() {
552552
"#]],
553553
);
554554
}
555+
556+
#[cargo_test]
557+
fn trailing_separator_after_package_root_build_script() {
558+
let p = project()
559+
.file(
560+
"Cargo.toml",
561+
r#"
562+
[package]
563+
name = "foo"
564+
version = "0.0.1"
565+
authors = []
566+
"#,
567+
)
568+
.file("src/main.rs", "fn main() {}")
569+
.file(
570+
"build.rs",
571+
r#"
572+
fn main() {
573+
println!("cargo::rerun-if-changed=");
574+
}
575+
"#,
576+
)
577+
.build();
578+
579+
p.cargo("build").run();
580+
let contents = p.read_file("target/debug/foo.d");
581+
582+
assert_e2e().eq(
583+
&contents,
584+
str![[r#"
585+
[ROOT]/foo/target/debug/foo[EXE]: [ROOT]/foo/ [ROOT]/foo/build.rs [ROOT]/foo/src/main.rs
586+
587+
"#]],
588+
);
589+
}
590+
591+
#[cargo_test(nightly, reason = "proc_macro::tracked_path is unstable")]
592+
fn trailing_separator_after_package_root_proc_macro() {
593+
let p = project()
594+
.file(
595+
"Cargo.toml",
596+
r#"
597+
[package]
598+
name = "foo"
599+
version = "0.0.1"
600+
authors = []
601+
edition = "2018"
602+
603+
[dependencies]
604+
pm = { path = "pm" }
605+
"#,
606+
)
607+
.file(
608+
"src/main.rs",
609+
"
610+
pm::noop!{}
611+
fn main() {}
612+
",
613+
)
614+
.file(
615+
"pm/Cargo.toml",
616+
r#"
617+
[package]
618+
name = "pm"
619+
version = "0.1.0"
620+
edition = "2018"
621+
622+
[lib]
623+
proc-macro = true
624+
"#,
625+
)
626+
.file(
627+
"pm/src/lib.rs",
628+
r#"
629+
#![feature(track_path)]
630+
extern crate proc_macro;
631+
use proc_macro::TokenStream;
632+
633+
#[proc_macro]
634+
pub fn noop(_item: TokenStream) -> TokenStream {
635+
proc_macro::tracked_path::path(
636+
std::env::current_dir().unwrap().to_str().unwrap()
637+
);
638+
"".parse().unwrap()
639+
}
640+
"#,
641+
)
642+
.build();
643+
644+
p.cargo("build").run();
645+
let contents = p.read_file("target/debug/foo.d");
646+
647+
assert_e2e().eq(
648+
&contents,
649+
str![[r#"
650+
[ROOT]/foo/target/debug/foo[EXE]: [ROOT]/foo/ [ROOT]/foo/pm/src/lib.rs [ROOT]/foo/src/main.rs
651+
652+
"#]],
653+
);
654+
}

0 commit comments

Comments
 (0)