Skip to content

Commit

Permalink
Normalize cargo home in UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Nov 25, 2024
1 parent 7db7489 commit 2ab3525
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2332,6 +2332,20 @@ impl<'test> TestCx<'test> {
// eg. /home/user/rust/build
normalize_path(parent_build_dir, "$BUILD_DIR");

// e.g. /home/user/.cargo
if let Ok(cargo_home) = home::cargo_home() {
let mut from = cargo_home.display().to_string();
if json {
from = from.replace("\\", "\\\\");
}
// In CI, `$CARGO_HOME` is `/cargo`, but some paths in output contain `.../cargo...`
// Try to normalize only paths beginning with `$CARGO_HOME`
for prefix in [' ', '\n', '\'', '"'] {
normalized =
normalized.replace(&format!("{prefix}{from}"), &format!("{prefix}{from}"));
}
}

if json {
// escaped newlines in json strings should be readable
// in the stderr files. There's no point int being correct,
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/issues/issue-21763.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Regression test for HashMap only impl'ing Send/Sync if its contents do

//@ normalize-stderr-test: "\S+[\\/]hashbrown\S+" -> "$$HASHBROWN_SRC_LOCATION"

use std::collections::HashMap;
use std::rc::Rc;

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/issues/issue-21763.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: `Rc<()>` cannot be sent between threads safely
--> $DIR/issue-21763.rs:11:11
--> $DIR/issue-21763.rs:9:11
|
LL | foo::<HashMap<Rc<()>, Rc<()>>>();
| ^^^^^^^^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely
Expand All @@ -8,11 +8,11 @@ LL | foo::<HashMap<Rc<()>, Rc<()>>>();
= note: required because it appears within the type `(Rc<()>, Rc<()>)`
= note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send`
note: required because it appears within the type `hashbrown::map::HashMap<Rc<()>, Rc<()>, RandomState>`
--> $HASHBROWN_SRC_LOCATION
--> $CARGO_HOME/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.15.0/src/map.rs:185:12
note: required because it appears within the type `HashMap<Rc<()>, Rc<()>>`
--> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
note: required by a bound in `foo`
--> $DIR/issue-21763.rs:8:11
--> $DIR/issue-21763.rs:6:11
|
LL | fn foo<T: Send>() {}
| ^^^^ required by this bound in `foo`
Expand Down

0 comments on commit 2ab3525

Please sign in to comment.