Skip to content

Commit 686477f

Browse files
committed
Normalize cargo home in UI tests
1 parent 33c245b commit 686477f

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,6 +2383,20 @@ impl<'test> TestCx<'test> {
23832383
// eg. /home/user/rust/build
23842384
normalize_path(parent_build_dir, "$BUILD_DIR");
23852385

2386+
// e.g. /home/user/.cargo
2387+
if let Ok(cargo_home) = home::cargo_home() {
2388+
let mut from = cargo_home.display().to_string();
2389+
if json {
2390+
from = from.replace("\\", "\\\\");
2391+
}
2392+
// In CI, `$CARGO_HOME` is `/cargo`, but some paths in output contain `.../cargo...`
2393+
// Try to normalize only paths beginning with `$CARGO_HOME`
2394+
for prefix in [' ', '\n', '\'', '"'] {
2395+
normalized =
2396+
normalized.replace(&format!("{prefix}{from}"), &format!("{prefix}$CARGO_HOME"));
2397+
}
2398+
}
2399+
23862400
if json {
23872401
// escaped newlines in json strings should be readable
23882402
// in the stderr files. There's no point int being correct,

tests/ui/issues/issue-21763.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Regression test for HashMap only impl'ing Send/Sync if its contents do
22

3-
//@ normalize-stderr-test: "\S+[\\/]hashbrown\S+" -> "$$HASHBROWN_SRC_LOCATION"
4-
53
use std::collections::HashMap;
64
use std::rc::Rc;
75

tests/ui/issues/issue-21763.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: `Rc<()>` cannot be sent between threads safely
2-
--> $DIR/issue-21763.rs:11:11
2+
--> $DIR/issue-21763.rs:9:11
33
|
44
LL | foo::<HashMap<Rc<()>, Rc<()>>>();
55
| ^^^^^^^^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely
@@ -8,11 +8,11 @@ LL | foo::<HashMap<Rc<()>, Rc<()>>>();
88
= note: required because it appears within the type `(Rc<()>, Rc<()>)`
99
= note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send`
1010
note: required because it appears within the type `hashbrown::map::HashMap<Rc<()>, Rc<()>, RandomState>`
11-
--> $HASHBROWN_SRC_LOCATION
11+
--> $CARGO_HOME/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.15.0/src/map.rs:185:12
1212
note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>`
1313
--> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
1414
note: required by a bound in `foo`
15-
--> $DIR/issue-21763.rs:8:11
15+
--> $DIR/issue-21763.rs:6:11
1616
|
1717
LL | fn foo<T: Send>() {}
1818
| ^^^^ required by this bound in `foo`

0 commit comments

Comments
 (0)