Skip to content

Commit

Permalink
Add tests for runtime-ignored trials
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Widawsky <[email protected]>

(most of this is from Ben)
  • Loading branch information
tgross35 committed Dec 20, 2024
1 parent 5385965 commit 513d7f7
Showing 1 changed file with 95 additions and 32 deletions.
127 changes: 95 additions & 32 deletions tests/all_passing.rs
Original file line number Diff line number Diff line change
@@ -1,44 +1,62 @@
use common::{args, check};
use libtest_mimic::{Trial, Conclusion};
use libtest_mimic::{Completion, Conclusion, Trial};
use pretty_assertions::assert_eq;

use crate::common::do_run;

#[macro_use]
mod common;


fn tests() -> Vec<Trial> {
vec![
Trial::test("foo", || Ok(())),
Trial::test("bar", || Ok(())),
Trial::test("barro", || Ok(())),
// Passed
Trial::skippable_test("baz", || Ok(Completion::Completed)),
// Ignored with a reason
Trial::skippable_test("qux", || {
Ok(Completion::Ignored {
reason: "very valid reason".into(),
})
}),
// Ignored with no reason
Trial::skippable_test("quux", || Ok(Completion::Ignored { reason: "".into(), })),
]
}

#[test]
fn normal() {
check(args([]), tests, 3,
check(
args([]),
tests,
6,
Conclusion {
num_filtered_out: 0,
num_passed: 3,
num_passed: 4,
num_failed: 0,
num_ignored: 0,
num_ignored: 2,
num_measured: 0,
},
"
test foo ... ok
test bar ... ok
test barro ... ok
"
test baz ... ok
test qux ... ignored, very valid reason
test quux ... ignored
",
);
}

#[test]
fn filter_one() {
check(args(["foo"]), tests, 1,
check(
args(["foo"]),
tests,
1,
Conclusion {
num_filtered_out: 2,
num_filtered_out: 5,
num_passed: 1,
num_failed: 0,
num_ignored: 0,
Expand All @@ -50,9 +68,12 @@ fn filter_one() {

#[test]
fn filter_two() {
check(args(["bar"]), tests, 2,
check(
args(["bar"]),
tests,
2,
Conclusion {
num_filtered_out: 1,
num_filtered_out: 4,
num_passed: 2,
num_failed: 0,
num_ignored: 0,
Expand All @@ -65,12 +86,14 @@ fn filter_two() {
);
}


#[test]
fn filter_exact() {
check(args(["bar", "--exact"]), tests, 1,
check(
args(["bar", "--exact"]),
tests,
1,
Conclusion {
num_filtered_out: 2,
num_filtered_out: 5,
num_passed: 1,
num_failed: 0,
num_ignored: 0,
Expand All @@ -82,9 +105,12 @@ fn filter_exact() {

#[test]
fn filter_two_and_skip() {
check(args(["--skip", "barro", "bar"]), tests, 1,
check(
args(["--skip", "barro", "bar"]),
tests,
1,
Conclusion {
num_filtered_out: 2,
num_filtered_out: 5,
num_passed: 1,
num_failed: 0,
num_ignored: 0,
Expand All @@ -94,52 +120,89 @@ fn filter_two_and_skip() {
);
}

#[test]
fn filter_runtime_ignored() {
check(
args(["qux", "--exact"]),
tests,
1,
Conclusion {
num_filtered_out: 5,
num_passed: 0,
num_failed: 0,
num_ignored: 1,
num_measured: 0,
},
"test qux ... ignored, very valid reason",
);
}

#[test]
fn skip_nothing() {
check(args(["--skip", "peter"]), tests, 3,
check(
args(["--skip", "peter"]),
tests,
6,
Conclusion {
num_filtered_out: 0,
num_passed: 3,
num_passed: 4,
num_failed: 0,
num_ignored: 0,
num_ignored: 2,
num_measured: 0,
},
"
test foo ... ok
test bar ... ok
test barro ... ok
"
test baz ... ok
test qux ... ignored, very valid reason
test quux ... ignored
",
);
}

#[test]
fn skip_two() {
check(args(["--skip", "bar"]), tests, 1,
check(
args(["--skip", "bar"]),
tests,
4,
Conclusion {
num_filtered_out: 2,
num_passed: 1,
num_passed: 2,
num_failed: 0,
num_ignored: 0,
num_ignored: 2,
num_measured: 0,
},
"test foo ... ok"
"
test foo ... ok
test baz ... ok
test qux ... ignored, very valid reason
test quux ... ignored
",
);
}

#[test]
fn skip_exact() {
check(args(["--exact", "--skip", "bar"]), tests, 2,
check(
args(["--exact", "--skip", "bar"]),
tests,
5,
Conclusion {
num_filtered_out: 1,
num_passed: 2,
num_passed: 3,
num_failed: 0,
num_ignored: 0,
num_ignored: 2,
num_measured: 0,
},
"
test foo ... ok
test barro ... ok
"
test baz ... ok
test qux ... ignored, very valid reason
test quux ... ignored
",
);
}

Expand All @@ -148,15 +211,15 @@ fn terse_output() {
let (c, out) = do_run(args(["--format", "terse"]), tests());
assert_eq!(c, Conclusion {
num_filtered_out: 0,
num_passed: 3,
num_passed: 4,
num_failed: 0,
num_ignored: 0,
num_ignored: 2,
num_measured: 0,
});
assert_log!(out, "
running 3 tests
...
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; \
running 6 tests
....SS
test result: ok. 4 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out; \
finished in 0.00s
");
}

0 comments on commit 513d7f7

Please sign in to comment.