Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate run-make/allow-non-lint-warnings-cmdline to rmake.rs #126386

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/tools/run-make-support/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -167,6 +167,12 @@ impl CompletedProcess {
self
}

#[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());
Expand All @@ -182,7 +188,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
}

Expand Down
12 changes: 12 additions & 0 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,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) {
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 0 additions & 12 deletions tests/run-make/allow-non-lint-warnings-cmdline/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//@ compile-flags: -Awarnings
//@ check-pass

#[derive()]
#[derive(Copy, Clone)]
pub struct Foo;
Expand Down
Loading