Skip to content

Commit 39d2174

Browse files
committed
Add an edge-case test for --remap-path-prefix for rustc & rustdoc
1 parent 4dbafc3 commit 39d2174

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)