Skip to content

refactor(test): Remove dead 'expect_stdout_contains_n' check #14759

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

Merged
merged 1 commit into from
Oct 31, 2024
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
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
Loading