Skip to content

Commit

Permalink
fix(test): Remove dead 'expect_stdout_contains_n' check
Browse files Browse the repository at this point in the history
This was missed when removing the assert
  • Loading branch information
epage committed Oct 31, 2024
1 parent 497c228 commit 9865bc2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 40 deletions.
34 changes: 0 additions & 34 deletions crates/cargo-test-support/src/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,40 +531,6 @@ pub(crate) fn match_does_not_contain(
}
}

/// Checks that the given string contains the given contiguous lines
/// somewhere, and should be repeated `number` times.
///
/// See [Patterns](index.html#patterns) for more information on pattern matching.
pub(crate) fn match_contains_n(
expected: &str,
number: usize,
actual: &str,
cwd: Option<&Path>,
) -> Result<()> {
let expected = normalize_expected(expected, cwd);
let actual = normalize_actual(actual, cwd);
let e: Vec<_> = expected.lines().map(|line| WildStr::new(line)).collect();
let a: Vec<_> = actual.lines().map(|line| WildStr::new(line)).collect();
if e.len() == 0 {
bail!("expected length must not be zero");
}
let matches = a.windows(e.len()).filter(|window| *window == e).count();
if matches == number {
Ok(())
} else {
bail!(
"expected to find {} occurrences of:\n\
{}\n\n\
but found {} matches in the output:\n\
{}",
number,
expected,
matches,
actual
)
}
}

/// Checks that the given string has a line that contains the given patterns,
/// and that line also does not contain the `without` patterns.
///
Expand Down
6 changes: 0 additions & 6 deletions crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,6 @@ pub struct Execs {
expect_stderr_data: Option<snapbox::Data>,
expect_stdout_contains: Vec<String>,
expect_stderr_contains: Vec<String>,
expect_stdout_contains_n: Vec<(String, usize)>,
expect_stdout_not_contains: Vec<String>,
expect_stderr_not_contains: Vec<String>,
expect_stdout_unordered: Vec<String>,
Expand Down Expand Up @@ -992,7 +991,6 @@ impl Execs {
&& self.expect_stderr_data.is_none()
&& self.expect_stdout_contains.is_empty()
&& self.expect_stderr_contains.is_empty()
&& self.expect_stdout_contains_n.is_empty()
&& self.expect_stdout_not_contains.is_empty()
&& self.expect_stderr_not_contains.is_empty()
&& self.expect_stdout_unordered.is_empty()
Expand Down Expand Up @@ -1103,9 +1101,6 @@ impl Execs {
for expect in self.expect_stderr_contains.iter() {
compare::match_contains(expect, stderr, cwd)?;
}
for &(ref expect, number) in self.expect_stdout_contains_n.iter() {
compare::match_contains_n(expect, number, stdout, cwd)?;
}
for expect in self.expect_stdout_not_contains.iter() {
compare::match_does_not_contain(expect, stdout, cwd)?;
}
Expand Down Expand Up @@ -1144,7 +1139,6 @@ pub fn execs() -> Execs {
expect_stderr_data: None,
expect_stdout_contains: Vec::new(),
expect_stderr_contains: Vec::new(),
expect_stdout_contains_n: Vec::new(),
expect_stdout_not_contains: Vec::new(),
expect_stderr_not_contains: Vec::new(),
expect_stdout_unordered: Vec::new(),
Expand Down

0 comments on commit 9865bc2

Please sign in to comment.