Improve run-make-support
API for assert*
functions
This commit is contained in:
parent
7b21c18fe4
commit
b5b97dccae
@ -185,14 +185,14 @@ impl CompletedProcess {
|
|||||||
/// Checks that `stdout` does not contain `unexpected`.
|
/// Checks that `stdout` does not contain `unexpected`.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
|
pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
|
||||||
assert_not_contains(&self.stdout_utf8(), unexpected.as_ref());
|
assert_not_contains(&self.stdout_utf8(), unexpected);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks that `stdout` contains `expected`.
|
/// Checks that `stdout` contains `expected`.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn assert_stdout_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
|
pub fn assert_stdout_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
|
||||||
assert_contains(&self.stdout_utf8(), expected.as_ref());
|
assert_contains(&self.stdout_utf8(), expected);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,14 +206,14 @@ impl CompletedProcess {
|
|||||||
/// Checks that `stderr` contains `expected`.
|
/// Checks that `stderr` contains `expected`.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn assert_stderr_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
|
pub fn assert_stderr_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
|
||||||
assert_contains(&self.stderr_utf8(), expected.as_ref());
|
assert_contains(&self.stderr_utf8(), expected);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks that `stderr` does not contain `unexpected`.
|
/// Checks that `stderr` does not contain `unexpected`.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn assert_stderr_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
|
pub fn assert_stderr_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
|
||||||
assert_not_contains(&self.stdout_utf8(), unexpected.as_ref());
|
assert_not_contains(&self.stdout_utf8(), unexpected);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +409,9 @@ pub fn read_dir<F: FnMut(&Path)>(dir: impl AsRef<Path>, mut callback: F) {
|
|||||||
|
|
||||||
/// Check that `actual` is equal to `expected`. Panic otherwise.
|
/// Check that `actual` is equal to `expected`. Panic otherwise.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn assert_equals(actual: &str, expected: &str) {
|
pub fn assert_equals<S1: AsRef<str>, S2: AsRef<str>>(actual: S1, expected: S2) {
|
||||||
|
let actual = actual.as_ref();
|
||||||
|
let expected = expected.as_ref();
|
||||||
if actual != expected {
|
if actual != expected {
|
||||||
eprintln!("=== ACTUAL TEXT ===");
|
eprintln!("=== ACTUAL TEXT ===");
|
||||||
eprintln!("{}", actual);
|
eprintln!("{}", actual);
|
||||||
@ -421,7 +423,9 @@ pub fn assert_equals(actual: &str, expected: &str) {
|
|||||||
|
|
||||||
/// Check that `haystack` contains `needle`. Panic otherwise.
|
/// Check that `haystack` contains `needle`. Panic otherwise.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn assert_contains(haystack: &str, needle: &str) {
|
pub fn assert_contains<S1: AsRef<str>, S2: AsRef<str>>(haystack: S1, needle: S2) {
|
||||||
|
let haystack = haystack.as_ref();
|
||||||
|
let needle = needle.as_ref();
|
||||||
if !haystack.contains(needle) {
|
if !haystack.contains(needle) {
|
||||||
eprintln!("=== HAYSTACK ===");
|
eprintln!("=== HAYSTACK ===");
|
||||||
eprintln!("{}", haystack);
|
eprintln!("{}", haystack);
|
||||||
@ -433,7 +437,9 @@ pub fn assert_contains(haystack: &str, needle: &str) {
|
|||||||
|
|
||||||
/// Check that `haystack` does not contain `needle`. Panic otherwise.
|
/// Check that `haystack` does not contain `needle`. Panic otherwise.
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn assert_not_contains(haystack: &str, needle: &str) {
|
pub fn assert_not_contains<S1: AsRef<str>, S2: AsRef<str>>(haystack: S1, needle: S2) {
|
||||||
|
let haystack = haystack.as_ref();
|
||||||
|
let needle = needle.as_ref();
|
||||||
if haystack.contains(needle) {
|
if haystack.contains(needle) {
|
||||||
eprintln!("=== HAYSTACK ===");
|
eprintln!("=== HAYSTACK ===");
|
||||||
eprintln!("{}", haystack);
|
eprintln!("{}", haystack);
|
||||||
|
@ -23,8 +23,8 @@ fn check_compression(compression: &str, to_find: &str) {
|
|||||||
cmd("readelf").arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
|
cmd("readelf").arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
|
||||||
} else {
|
} else {
|
||||||
assert_contains(
|
assert_contains(
|
||||||
&stderr,
|
stderr,
|
||||||
&format!("unknown debuginfo compression algorithm {compression}"),
|
format!("unknown debuginfo compression algorithm {compression}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user