diff options
| author | bors <bors@rust-lang.org> | 2024-06-14 09:19:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-06-14 09:19:38 +0000 |
| commit | 63491e10125d6bac9da9b80f4969c18afa28bcc1 (patch) | |
| tree | 8d9d3534fac0b48e48a12fd2fbdd52ef10c30298 /src | |
| parent | d2ad293851dc8e14a61355d0358490b77efae8cb (diff) | |
| parent | edd4c97b810bcbb89d08238e4596ae2564d46ba6 (diff) | |
| download | rust-63491e10125d6bac9da9b80f4969c18afa28bcc1.tar.gz rust-63491e10125d6bac9da9b80f4969c18afa28bcc1.zip | |
Auto merge of #126463 - matthiaskrgr:rollup-lnkfibf, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #124884 (place explicit lifetime bound after generic param) - #126343 (Remove some msys2 utils) - #126351 (std::unix::fs::link using direct linkat call for Solaris.) - #126368 (Remove some unnecessary crate dependencies.) - #126386 (Migrate `run-make/allow-non-lint-warnings-cmdline` to `rmake.rs`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/run-make-support/src/command.rs | 10 | ||||
| -rw-r--r-- | src/tools/run-make-support/src/lib.rs | 12 | ||||
| -rw-r--r-- | src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 |
3 files changed, 20 insertions, 3 deletions
diff --git a/src/tools/run-make-support/src/command.rs b/src/tools/run-make-support/src/command.rs index 7cbc61bdf33..dab18dca2ff 100644 --- a/src/tools/run-make-support/src/command.rs +++ b/src/tools/run-make-support/src/command.rs @@ -6,7 +6,7 @@ use std::path::Path; use std::process::{Command as StdCommand, ExitStatus, Output, Stdio}; use crate::drop_bomb::DropBomb; -use crate::{assert_not_contains, handle_failed_output}; +use crate::{assert_contains, assert_not_contains, handle_failed_output}; /// This is a custom command wrapper that simplifies working with commands and makes it easier to /// ensure that we check the exit status of executed processes. @@ -171,6 +171,12 @@ impl CompletedProcess { } #[track_caller] + pub fn assert_stdout_contains<S: AsRef<str>>(self, needle: S) -> Self { + assert_contains(&self.stdout_utf8(), needle.as_ref()); + self + } + + #[track_caller] pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, needle: S) -> &Self { assert_not_contains(&self.stdout_utf8(), needle.as_ref()); self @@ -185,7 +191,7 @@ impl CompletedProcess { #[track_caller] pub fn assert_stderr_contains<S: AsRef<str>>(&self, needle: S) -> &Self { - assert!(self.stderr_utf8().contains(needle.as_ref())); + assert_contains(&self.stderr_utf8(), needle.as_ref()); self } diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index d077c500c5d..ba4524c150c 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -332,6 +332,18 @@ pub fn read_dir<F: Fn(&Path)>(dir: impl AsRef<Path>, callback: F) { } } +/// Check that `haystack` contains `needle`. Panic otherwise. +#[track_caller] +pub fn assert_contains(haystack: &str, needle: &str) { + if !haystack.contains(needle) { + eprintln!("=== HAYSTACK ==="); + eprintln!("{}", haystack); + eprintln!("=== NEEDLE ==="); + eprintln!("{}", needle); + panic!("needle was not found in haystack"); + } +} + /// Check that `haystack` does not contain `needle`. Panic otherwise. #[track_caller] pub fn assert_not_contains(haystack: &str, needle: &str) { diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 14d7bfe9ad4..be9df226d64 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -1,5 +1,4 @@ run-make/allocator-shim-circular-deps/Makefile -run-make/allow-non-lint-warnings-cmdline/Makefile run-make/archive-duplicate-names/Makefile run-make/atomic-lock-free/Makefile run-make/branch-protection-check-IBT/Makefile |
