Skip to content

Commit

Permalink
avoid blessing cargo deps's source code in ui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pietroalbini committed Sep 15, 2023
1 parent d695b95 commit c230637
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ dependencies = [
"diff",
"getopts",
"glob",
"home",
"lazycell",
"libc",
"miow",
Expand Down Expand Up @@ -1597,6 +1598,15 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"

[[package]]
name = "home"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
dependencies = [
"windows-sys 0.48.0",
]

[[package]]
name = "html-checker"
version = "0.1.0"
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ walkdir = "2"
glob = "0.3.0"
lazycell = "1.3.0"
anyhow = "1"
home = "0.5.5"

[target.'cfg(unix)'.dependencies]
libc = "0.2"
Expand Down
9 changes: 9 additions & 0 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2335,6 +2335,15 @@ impl<'test> TestCx<'test> {
rustc.arg("-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX");
rustc.arg("-Ztranslate-remapped-path-to-local-path=no");

// Hide Cargo dependency sources from ui tests to make sure the error message doesn't
// change depending on whether $CARGO_HOME is remapped or not. If this is not present,
// when $CARGO_HOME is remapped the source won't be shown, and when it's not remapped the
// source will be shown, causing a blessing hell.
rustc.arg("-Z").arg(format!(
"ignore-directory-in-diagnostics-source-blocks={}",
home::cargo_home().expect("failed to find cargo home").to_str().unwrap()
));

// Optionally prevent default --sysroot if specified in test compile-flags.
if !self.props.compile_flags.iter().any(|flag| flag.starts_with("--sysroot"))
&& !self.config.host_rustcflags.iter().any(|flag| flag == "--sysroot")
Expand Down
3 changes: 0 additions & 3 deletions tests/ui/issues/issue-21763.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ LL | foo::<HashMap<Rc<()>, Rc<()>>>();
= note: required for `hashbrown::raw::RawTable<(Rc<()>, Rc<()>)>` to implement `Send`
note: required because it appears within the type `HashMap<Rc<()>, Rc<()>, RandomState>`
--> $HASHBROWN_SRC_LOCATION
|
LL | pub struct HashMap<K, V, S = DefaultHashBuilder, A: Allocator + Clone = Global> {
| ^^^^^^^
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`
Expand Down

0 comments on commit c230637

Please sign in to comment.