Skip to content

Commit

Permalink
Rollup merge of #131576 - Zalathar:tests-tests, r=jieyouxu
Browse files Browse the repository at this point in the history
Flatten redundant test module `run_make_support::diff::tests::tests`

This module is already named `tests`, and is already gated by `#[cfg(test)]`, so there's no need for it to also contain `mod tests`.

r? jieyouxu
  • Loading branch information
tgross35 authored Oct 12, 2024
2 parents 1f31925 + f4376c4 commit 5e477c9
Showing 1 changed file with 30 additions and 36 deletions.
66 changes: 30 additions & 36 deletions src/tools/run-make-support/src/diff/tests.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
#[cfg(test)]
mod tests {
use crate::*;

#[test]
fn test_diff() {
let expected = "foo\nbar\nbaz\n";
let actual = "foo\nbar\nbaz\n";
use crate::diff;

#[test]
fn test_diff() {
let expected = "foo\nbar\nbaz\n";
let actual = "foo\nbar\nbaz\n";
diff().expected_text("EXPECTED_TEXT", expected).actual_text("ACTUAL_TEXT", actual).run();
}

#[test]
fn test_should_panic() {
let expected = "foo\nbar\nbaz\n";
let actual = "foo\nbaz\nbar\n";

let output = std::panic::catch_unwind(|| {
diff().expected_text("EXPECTED_TEXT", expected).actual_text("ACTUAL_TEXT", actual).run();
}

#[test]
fn test_should_panic() {
let expected = "foo\nbar\nbaz\n";
let actual = "foo\nbaz\nbar\n";

let output = std::panic::catch_unwind(|| {
diff()
.expected_text("EXPECTED_TEXT", expected)
.actual_text("ACTUAL_TEXT", actual)
.run();
})
.unwrap_err();

let expected_output = "\
})
.unwrap_err();

let expected_output = "\
test failed: `EXPECTED_TEXT` is different from `ACTUAL_TEXT`
--- EXPECTED_TEXT
Expand All @@ -34,28 +29,27 @@ test failed: `EXPECTED_TEXT` is different from `ACTUAL_TEXT`
-baz
";

assert_eq!(output.downcast_ref::<String>().unwrap(), expected_output);
}
assert_eq!(output.downcast_ref::<String>().unwrap(), expected_output);
}

#[test]
fn test_normalize() {
let expected = "
#[test]
fn test_normalize() {
let expected = "
running 2 tests
..
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
";
let actual = "
let actual = "
running 2 tests
..
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
";

diff()
.expected_text("EXPECTED_TEXT", expected)
.actual_text("ACTUAL_TEXT", actual)
.normalize(r#"finished in \d+\.\d+s"#, "finished in $$TIME")
.run();
}
diff()
.expected_text("EXPECTED_TEXT", expected)
.actual_text("ACTUAL_TEXT", actual)
.normalize(r#"finished in \d+\.\d+s"#, "finished in $$TIME")
.run();
}

0 comments on commit 5e477c9

Please sign in to comment.