Skip to content

Commit 24cbae8

Browse files
Add assert_not_contains to run-make-support library
1 parent 21e6de7 commit 24cbae8

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
@@ -201,6 +201,17 @@ pub fn set_host_rpath(cmd: &mut Command) {
201201
});
202202
}
203203

204+
/// Check that `haystack` does not contain `needle`. Panic otherwise.
205+
pub fn assert_not_contains(haystack: &str, needle: &str) {
206+
if haystack.contains(needle) {
207+
eprintln!("=== HAYSTACK ===");
208+
eprintln!("{}", haystack);
209+
eprintln!("=== NEEDLE ===");
210+
eprintln!("{}", needle);
211+
panic!("needle was unexpectedly found in haystack");
212+
}
213+
}
214+
204215
/// Implement common helpers for command wrappers. This assumes that the command wrapper is a struct
205216
/// containing a `cmd: Command` field and a `output` function. The provided helpers are:
206217
///

0 commit comments

Comments
 (0)