Skip to content

Commit 7050d61

Browse files
Rollup merge of #155485 - Urgau:remap-edge-case-test, r=GuillaumeGomez
Add an edge-case test for `--remap-path-prefix` for `rustc` & `rustdoc` Intended to resolve @lolbinarycat concern #155307 (comment)
2 parents 1fe66ee + a755d0f commit 7050d61

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

  • tests/run-make/remap-path-prefix-edge-cases
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//! This test checks multiple edge-case of `--remap-path-prefix`.
2+
//!
3+
//! It tests:
4+
//! - `=` sign in FROM path
5+
//! - multiple path remappings
6+
//! - multiple conflicting path remappings
7+
8+
//@ ignore-windows (does not support directories with = sign)
9+
10+
use std::path::Path;
11+
12+
use run_make_support::{
13+
CompletedProcess, assert_contains, assert_not_contains, cwd, rfs, run_in_tmpdir, rustc, rustdoc,
14+
};
15+
16+
fn main() {
17+
run_in_tmpdir(|| {
18+
let out_dir = cwd();
19+
20+
// Create a directory with an `=` sign
21+
let eq_dir = out_dir.join("path=with=equal");
22+
rfs::create_dir_all(&eq_dir);
23+
24+
let src_path = eq_dir.join("lib.rs");
25+
rfs::write(&src_path, "pub fn broken_func() { ");
26+
27+
// Use multiple remap args and conflicting remappings
28+
let remap_args = [
29+
format!("--remap-path-prefix={}={}", eq_dir.display(), "REMAPPED_DIR"),
30+
format!("--remap-path-prefix={}={}", eq_dir.display(), "REMAPPED_DIR2"),
31+
];
32+
33+
fn run_test(cmd: impl FnOnce() -> CompletedProcess) {
34+
let output = cmd();
35+
let stderr = output.stderr_utf8();
36+
37+
// Checks the diagnostic output
38+
assert_contains(&stderr, "REMAPPED_DIR2/lib.rs");
39+
assert_not_contains(&stderr, "REMAPPED_DIR/");
40+
assert_not_contains(&stderr, "path=with=equal");
41+
};
42+
43+
// Test with rustc
44+
run_test(|| rustc().input(&src_path).args(&remap_args).run_fail());
45+
46+
// Test with rustdoc
47+
run_test(|| {
48+
rustdoc().input(&src_path).arg("-Zunstable-options").args(&remap_args).run_fail()
49+
});
50+
});
51+
}

0 commit comments

Comments
 (0)