Skip to content

Commit dd0e396

Browse files
committed
Auto merge of #14759 - epage:test-contains-n, r=ehuss
refactor(test): Remove dead 'expect_stdout_contains_n' check ### What does this PR try to resolve? This was missed when removing the assert This is part of #14039 ### How should we test and review this PR? ### Additional information
2 parents 40d804b + 8a8254e commit dd0e396

File tree

2 files changed

+0
-40
lines changed

2 files changed

+0
-40
lines changed

crates/cargo-test-support/src/compare.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -531,40 +531,6 @@ pub(crate) fn match_does_not_contain(
531531
}
532532
}
533533

534-
/// Checks that the given string contains the given contiguous lines
535-
/// somewhere, and should be repeated `number` times.
536-
///
537-
/// See [Patterns](index.html#patterns) for more information on pattern matching.
538-
pub(crate) fn match_contains_n(
539-
expected: &str,
540-
number: usize,
541-
actual: &str,
542-
cwd: Option<&Path>,
543-
) -> Result<()> {
544-
let expected = normalize_expected(expected, cwd);
545-
let actual = normalize_actual(actual, cwd);
546-
let e: Vec<_> = expected.lines().map(|line| WildStr::new(line)).collect();
547-
let a: Vec<_> = actual.lines().map(|line| WildStr::new(line)).collect();
548-
if e.len() == 0 {
549-
bail!("expected length must not be zero");
550-
}
551-
let matches = a.windows(e.len()).filter(|window| *window == e).count();
552-
if matches == number {
553-
Ok(())
554-
} else {
555-
bail!(
556-
"expected to find {} occurrences of:\n\
557-
{}\n\n\
558-
but found {} matches in the output:\n\
559-
{}",
560-
number,
561-
expected,
562-
matches,
563-
actual
564-
)
565-
}
566-
}
567-
568534
/// Checks that the given string has a line that contains the given patterns,
569535
/// and that line also does not contain the `without` patterns.
570536
///

crates/cargo-test-support/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,6 @@ pub struct Execs {
649649
expect_stderr_data: Option<snapbox::Data>,
650650
expect_stdout_contains: Vec<String>,
651651
expect_stderr_contains: Vec<String>,
652-
expect_stdout_contains_n: Vec<(String, usize)>,
653652
expect_stdout_not_contains: Vec<String>,
654653
expect_stderr_not_contains: Vec<String>,
655654
expect_stdout_unordered: Vec<String>,
@@ -992,7 +991,6 @@ impl Execs {
992991
&& self.expect_stderr_data.is_none()
993992
&& self.expect_stdout_contains.is_empty()
994993
&& self.expect_stderr_contains.is_empty()
995-
&& self.expect_stdout_contains_n.is_empty()
996994
&& self.expect_stdout_not_contains.is_empty()
997995
&& self.expect_stderr_not_contains.is_empty()
998996
&& self.expect_stdout_unordered.is_empty()
@@ -1103,9 +1101,6 @@ impl Execs {
11031101
for expect in self.expect_stderr_contains.iter() {
11041102
compare::match_contains(expect, stderr, cwd)?;
11051103
}
1106-
for &(ref expect, number) in self.expect_stdout_contains_n.iter() {
1107-
compare::match_contains_n(expect, number, stdout, cwd)?;
1108-
}
11091104
for expect in self.expect_stdout_not_contains.iter() {
11101105
compare::match_does_not_contain(expect, stdout, cwd)?;
11111106
}
@@ -1144,7 +1139,6 @@ pub fn execs() -> Execs {
11441139
expect_stderr_data: None,
11451140
expect_stdout_contains: Vec::new(),
11461141
expect_stderr_contains: Vec::new(),
1147-
expect_stdout_contains_n: Vec::new(),
11481142
expect_stdout_not_contains: Vec::new(),
11491143
expect_stderr_not_contains: Vec::new(),
11501144
expect_stdout_unordered: Vec::new(),

0 commit comments

Comments
 (0)