Skip to content

Commit 5673337

Browse files
Add assert_not_contains to run-make-support library
1 parent c0d6003 commit 5673337

File tree

1 file changed

+11
-0
lines changed
  • src/tools/run-make-support/src

1 file changed

+11
-0
lines changed

src/tools/run-make-support/src/lib.rs

+11
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,17 @@ pub fn recursive_diff(dir1: impl AsRef<Path>, dir2: impl AsRef<Path>) {
268268
}
269269
}
270270

271+
/// Check that `haystack` does not contain `needle`. Panic otherwise.
272+
pub fn assert_not_contains(haystack: &str, needle: &str) {
273+
if haystack.contains(needle) {
274+
eprintln!("=== HAYSTACK ===");
275+
eprintln!("{}", haystack);
276+
eprintln!("=== NEEDLE ===");
277+
eprintln!("{}", needle);
278+
panic!("needle was unexpectedly found in haystack");
279+
}
280+
}
281+
271282
/// Implement common helpers for command wrappers. This assumes that the command wrapper is a struct
272283
/// containing a `cmd: Command` field and a `output` function. The provided helpers are:
273284
///

0 commit comments

Comments
 (0)