[PATCH] Fix UI tests with dist-vendored dependencies
authorJosh Stone <jistone@redhat.com>
Mon, 8 Apr 2024 22:04:44 +0000 (15:04 -0700)
committerFabian Grünbichler <debian@fabian.gruenbichler.email>
Wed, 19 Jun 2024 05:51:49 +0000 (07:51 +0200)
There is already a workaround in `compiletest` to deal with custom
`CARGO_HOME` using `-Zignore-directory-in-diagnostics-source-blocks={}`.
A similar need exists when dependencies come from the local `vendor`
directory, which distro builds often use, so now we ignore that too.

Also, `issue-21763.rs` was normalizing `hashbrown-` paths, presumably
expecting a version suffix, but the vendored path doesn't include the
version. Now that matches `[\\/]hashbrown` instead.

Forwarded: yes

Gbp-Pq: Topic upstream
Gbp-Pq: Name u-avoid-blessing-cargo-deps-s-source-code-in-ui-tests.patch

src/tools/compiletest/src/runtest.rs
tests/ui/issues/issue-21763.rs

index 5d53a4d28f2e28d34812bf6b5943f36bbb7adc49..9bb30ad5b1aa546b11bcdde355f6b989b946db60 100644 (file)
@@ -2342,6 +2342,11 @@ impl<'test> TestCx<'test> {
             "ignore-directory-in-diagnostics-source-blocks={}",
             home::cargo_home().expect("failed to find cargo home").to_str().unwrap()
         ));
+        // Similarly, vendored sources shouldn't be shown when running from a dist tarball.
+        rustc.arg("-Z").arg(format!(
+            "ignore-directory-in-diagnostics-source-blocks={}",
+            self.config.find_rust_src_root().unwrap().join("vendor").display(),
+        ));
 
         // Optionally prevent default --sysroot if specified in test compile-flags.
         if !self.props.compile_flags.iter().any(|flag| flag.starts_with("--sysroot"))
index 38103ff4f9c8549d10bb90cd68e186ccfabd9fa5..cc1a00687b3073bd21b7e518fe45e3a67fdefa8a 100644 (file)
@@ -1,6 +1,6 @@
 // Regression test for HashMap only impl'ing Send/Sync if its contents do
 
-// normalize-stderr-test: "\S+hashbrown-\S+" -> "$$HASHBROWN_SRC_LOCATION"
+// normalize-stderr-test: "\S+[\\/]hashbrown\S+" -> "$$HASHBROWN_SRC_LOCATION"
 
 use std::collections::HashMap;
 use std::rc::Rc;