diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-06-14 08:35:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-14 08:35:50 +0200 |
| commit | edd4c97b810bcbb89d08238e4596ae2564d46ba6 (patch) | |
| tree | 717055265ddbee509d83f293bbd5b873bbd1a92d | |
| parent | 9f2fc640f343a5f89e3243e56aa0b350f26dde30 (diff) | |
| parent | eca8d209d9c75ed0ba7ce434d62d9460d42271f5 (diff) | |
| download | rust-edd4c97b810bcbb89d08238e4596ae2564d46ba6.tar.gz rust-edd4c97b810bcbb89d08238e4596ae2564d46ba6.zip | |
Rollup merge of #126386 - GuillaumeGomez:migrate-run-make-allow-non-lint-warnings-cmdline, r=jieyouxu
Migrate `run-make/allow-non-lint-warnings-cmdline` to `rmake.rs` Part of https://github.com/rust-lang/rust/issues/121876. r? ```@jieyouxu```
| -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 | ||||
| -rw-r--r-- | tests/run-make/allow-non-lint-warnings-cmdline/Makefile | 12 | ||||
| -rw-r--r-- | tests/ui/allow-non-lint-warnings.rs (renamed from tests/run-make/allow-non-lint-warnings-cmdline/foo.rs) | 3 |
5 files changed, 23 insertions, 15 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 37da5d9c88d..280420d022d 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 diff --git a/tests/run-make/allow-non-lint-warnings-cmdline/Makefile b/tests/run-make/allow-non-lint-warnings-cmdline/Makefile deleted file mode 100644 index 78b9a7b9898..00000000000 --- a/tests/run-make/allow-non-lint-warnings-cmdline/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -# Test that -A warnings makes the 'empty trait list for derive' warning go away -OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" ) - -all: foo - test -z '$(OUT)' - -# This is just to make sure the above command actually succeeds -foo: - $(RUSTC) foo.rs -A warnings diff --git a/tests/run-make/allow-non-lint-warnings-cmdline/foo.rs b/tests/ui/allow-non-lint-warnings.rs index 02e8ccabf79..f8f5a78ebff 100644 --- a/tests/run-make/allow-non-lint-warnings-cmdline/foo.rs +++ b/tests/ui/allow-non-lint-warnings.rs @@ -1,3 +1,6 @@ +//@ compile-flags: -Awarnings +//@ check-pass + #[derive()] #[derive(Copy, Clone)] pub struct Foo; |
