Skip to content

Commit b509236

Browse files
committed
Add tests for runtime-ignored trials
Co-authored-by: Ben Widawsky <ben@bwidawsk.net> (most of this is from Ben)
1 parent 6c72e8d commit b509236

File tree

1 file changed

+99
-31
lines changed

1 file changed

+99
-31
lines changed

tests/all_passing.rs

Lines changed: 99 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,62 @@
11
use common::{args, check};
2-
use libtest_mimic::{Trial, Conclusion};
2+
use libtest_mimic::{Completion, Conclusion, Trial};
33
use pretty_assertions::assert_eq;
44

5-
use crate::common::{assert_reordered_log, conclusion_to_output, do_run};
5+
use crate::common::do_run;
66

77
#[macro_use]
88
mod common;
99

10-
1110
fn tests() -> Vec<Trial> {
1211
vec![
1312
Trial::test("foo", || Ok(())),
1413
Trial::test("bar", || Ok(())),
1514
Trial::test("barro", || Ok(())),
15+
// Passed
16+
Trial::skippable_test("baz", || Ok(Completion::Completed)),
17+
// Ignored with a reason
18+
Trial::skippable_test("qux", || {
19+
Ok(Completion::Ignored {
20+
reason: "very valid reason".into(),
21+
})
22+
}),
23+
// Ignored with no reason
24+
Trial::skippable_test("quux", || Ok(Completion::Ignored { reason: "".into(), })),
1625
]
1726
}
1827

1928
#[test]
2029
fn normal() {
21-
check(args([]), tests, 3,
30+
check(
31+
args([]),
32+
tests,
33+
6,
2234
Conclusion {
2335
num_filtered_out: 0,
24-
num_passed: 3,
36+
num_passed: 4,
2537
num_failed: 0,
26-
num_ignored: 0,
38+
num_ignored: 2,
2739
num_measured: 0,
2840
},
2941
"
3042
test foo ... ok
3143
test bar ... ok
3244
test barro ... ok
33-
"
45+
test baz ... ok
46+
test qux ... ignored, very valid reason
47+
test quux ... ignored
48+
",
3449
);
3550
}
3651

3752
#[test]
3853
fn filter_one() {
39-
check(args(["foo"]), tests, 1,
54+
check(
55+
args(["foo"]),
56+
tests,
57+
1,
4058
Conclusion {
41-
num_filtered_out: 2,
59+
num_filtered_out: 5,
4260
num_passed: 1,
4361
num_failed: 0,
4462
num_ignored: 0,
@@ -50,9 +68,12 @@ fn filter_one() {
5068

5169
#[test]
5270
fn filter_two() {
53-
check(args(["bar"]), tests, 2,
71+
check(
72+
args(["bar"]),
73+
tests,
74+
2,
5475
Conclusion {
55-
num_filtered_out: 1,
76+
num_filtered_out: 4,
5677
num_passed: 2,
5778
num_failed: 0,
5879
num_ignored: 0,
@@ -65,12 +86,14 @@ fn filter_two() {
6586
);
6687
}
6788

68-
6989
#[test]
7090
fn filter_exact() {
71-
check(args(["bar", "--exact"]), tests, 1,
91+
check(
92+
args(["bar", "--exact"]),
93+
tests,
94+
1,
7295
Conclusion {
73-
num_filtered_out: 2,
96+
num_filtered_out: 5,
7497
num_passed: 1,
7598
num_failed: 0,
7699
num_ignored: 0,
@@ -82,9 +105,12 @@ fn filter_exact() {
82105

83106
#[test]
84107
fn filter_two_and_skip() {
85-
check(args(["--skip", "barro", "bar"]), tests, 1,
108+
check(
109+
args(["--skip", "barro", "bar"]),
110+
tests,
111+
1,
86112
Conclusion {
87-
num_filtered_out: 2,
113+
num_filtered_out: 5,
88114
num_passed: 1,
89115
num_failed: 0,
90116
num_ignored: 0,
@@ -94,52 +120,89 @@ fn filter_two_and_skip() {
94120
);
95121
}
96122

123+
#[test]
124+
fn filter_runtime_ignored() {
125+
check(
126+
args(["qux", "--exact"]),
127+
tests,
128+
1,
129+
Conclusion {
130+
num_filtered_out: 5,
131+
num_passed: 0,
132+
num_failed: 0,
133+
num_ignored: 1,
134+
num_measured: 0,
135+
},
136+
"test qux ... ignored, very valid reason",
137+
);
138+
}
139+
97140
#[test]
98141
fn skip_nothing() {
99-
check(args(["--skip", "peter"]), tests, 3,
142+
check(
143+
args(["--skip", "peter"]),
144+
tests,
145+
6,
100146
Conclusion {
101147
num_filtered_out: 0,
102-
num_passed: 3,
148+
num_passed: 4,
103149
num_failed: 0,
104-
num_ignored: 0,
150+
num_ignored: 2,
105151
num_measured: 0,
106152
},
107153
"
108154
test foo ... ok
109155
test bar ... ok
110156
test barro ... ok
111-
"
157+
test baz ... ok
158+
test qux ... ignored, very valid reason
159+
test quux ... ignored
160+
",
112161
);
113162
}
114163

115164
#[test]
116165
fn skip_two() {
117-
check(args(["--skip", "bar"]), tests, 1,
166+
check(
167+
args(["--skip", "bar"]),
168+
tests,
169+
4,
118170
Conclusion {
119171
num_filtered_out: 2,
120-
num_passed: 1,
172+
num_passed: 2,
121173
num_failed: 0,
122-
num_ignored: 0,
174+
num_ignored: 2,
123175
num_measured: 0,
124176
},
125-
"test foo ... ok"
177+
"
178+
test foo ... ok
179+
test baz ... ok
180+
test qux ... ignored, very valid reason
181+
test quux ... ignored
182+
",
126183
);
127184
}
128185

129186
#[test]
130187
fn skip_exact() {
131-
check(args(["--exact", "--skip", "bar"]), tests, 2,
188+
check(
189+
args(["--exact", "--skip", "bar"]),
190+
tests,
191+
5,
132192
Conclusion {
133193
num_filtered_out: 1,
134-
num_passed: 2,
194+
num_passed: 3,
135195
num_failed: 0,
136-
num_ignored: 0,
196+
num_ignored: 2,
137197
num_measured: 0,
138198
},
139199
"
140200
test foo ... ok
141201
test barro ... ok
142-
"
202+
test baz ... ok
203+
test qux ... ignored, very valid reason
204+
test quux ... ignored
205+
",
143206
);
144207
}
145208

@@ -148,10 +211,15 @@ fn terse_output() {
148211
let (c, out) = do_run(args(["--format", "terse"]), tests());
149212
assert_eq!(c, Conclusion {
150213
num_filtered_out: 0,
151-
num_passed: 3,
214+
num_passed: 4,
152215
num_failed: 0,
153-
num_ignored: 0,
216+
num_ignored: 2,
154217
num_measured: 0,
155218
});
156-
assert_reordered_log(out.as_str(), 3, &["..."], &conclusion_to_output(&c));
219+
assert_log!(out, "
220+
running 6 tests
221+
....SS
222+
test result: ok. 4 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out; \
223+
finished in 0.00s
224+
");
157225
}

0 commit comments

Comments
 (0)