Rework -Zremap-path-scope macro test with dependency check

This commit is contained in:
Urgau 2025-05-06 22:59:49 +02:00
parent fc0f0a8add
commit f959039994
15 changed files with 103 additions and 9 deletions

View file

@ -0,0 +1,11 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=debuginfo
#[macro_export]
macro_rules! my_file {
() => { file!() }
}
pub fn file() -> &'static str {
file!()
}

View file

@ -0,0 +1,11 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=diagnostics
#[macro_export]
macro_rules! my_file {
() => { file!() }
}
pub fn file() -> &'static str {
file!()
}

View file

@ -0,0 +1,11 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=macro
#[macro_export]
macro_rules! my_file {
() => { file!() }
}
pub fn file() -> &'static str {
file!()
}

View file

@ -0,0 +1,8 @@
#[macro_export]
macro_rules! my_file {
() => { file!() }
}
pub fn file() -> &'static str {
file!()
}

View file

@ -1 +0,0 @@
remapped/errors/remap-path-prefix-macro.rs

View file

@ -0,0 +1,3 @@
file::my_file!() = remapped/errors/remap-path-prefix-macro.rs
file::file() = $DIR/auxiliary/file.rs
file!() = remapped/errors/remap-path-prefix-macro.rs

View file

@ -0,0 +1,3 @@
file::my_file!() = $DIR/remap-path-prefix-macro.rs
file::file() = $DIR/auxiliary/file-debuginfo.rs
file!() = $DIR/remap-path-prefix-macro.rs

View file

@ -0,0 +1,3 @@
file::my_file!() = $DIR/remap-path-prefix-macro.rs
file::file() = $DIR/auxiliary/file-diag.rs
file!() = $DIR/remap-path-prefix-macro.rs

View file

@ -0,0 +1,3 @@
file::my_file!() = $DIR/remap-path-prefix-macro.rs
file::file() = remapped/errors/auxiliary/file-macro.rs
file!() = $DIR/remap-path-prefix-macro.rs

View file

@ -1,12 +1,47 @@
// This test exercises `-Zremap-path-scope`, macros (like file!()) and dependency.
//
// We test different combinations with/without remap in deps, with/without remap in
// this crate but always in deps and always here but never in deps.
//@ run-pass
//@ check-run-results
//@ revisions: normal with-macro-scope without-macro-scope
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ [with-macro-scope]compile-flags: -Zremap-path-scope=macro,diagnostics
//@ [without-macro-scope]compile-flags: -Zremap-path-scope=diagnostics
// no-remap-src-base: Manually remap, so the remapped path remains in .stderr file.
//@ revisions: with-diag-in-deps with-macro-in-deps with-debuginfo-in-deps
//@ revisions: only-diag-in-deps only-macro-in-deps only-debuginfo-in-deps
//@ revisions: not-macro-in-deps
//@[with-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
//@[with-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
//@[with-debuginfo-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
//@[not-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
//@[with-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics
//@[with-macro-in-deps] compile-flags: -Zremap-path-scope=macro
//@[with-debuginfo-in-deps] compile-flags: -Zremap-path-scope=debuginfo
//@[not-macro-in-deps] compile-flags: -Zremap-path-scope=macro
//@[with-diag-in-deps] aux-build:file-diag.rs
//@[with-macro-in-deps] aux-build:file-macro.rs
//@[with-debuginfo-in-deps] aux-build:file-debuginfo.rs
//@[only-diag-in-deps] aux-build:file-diag.rs
//@[only-macro-in-deps] aux-build:file-macro.rs
//@[only-debuginfo-in-deps] aux-build:file-debuginfo.rs
//@[not-macro-in-deps] aux-build:file.rs
#[cfg(any(with_diag_in_deps, only_diag_in_deps))]
extern crate file_diag as file;
#[cfg(any(with_macro_in_deps, only_macro_in_deps))]
extern crate file_macro as file;
#[cfg(any(with_debuginfo_in_deps, only_debuginfo_in_deps))]
extern crate file_debuginfo as file;
#[cfg(not_macro_in_deps)]
extern crate file;
fn main() {
println!("{}", file!());
println!("file::my_file!() = {}", file::my_file!());
println!("file::file() = {}", file::file());
println!("file!() = {}", file!());
}

View file

@ -0,0 +1,3 @@
file::my_file!() = $DIR/remap-path-prefix-macro.rs
file::file() = $DIR/auxiliary/file-debuginfo.rs
file!() = $DIR/remap-path-prefix-macro.rs

View file

@ -0,0 +1,3 @@
file::my_file!() = $DIR/remap-path-prefix-macro.rs
file::file() = $DIR/auxiliary/file-diag.rs
file!() = $DIR/remap-path-prefix-macro.rs

View file

@ -0,0 +1,3 @@
file::my_file!() = remapped/errors/remap-path-prefix-macro.rs
file::file() = remapped/errors/auxiliary/file-macro.rs
file!() = remapped/errors/remap-path-prefix-macro.rs

View file

@ -1 +0,0 @@
remapped/errors/remap-path-prefix-macro.rs

View file

@ -1 +0,0 @@
$DIR/remap-path-prefix-macro.rs