Skip to content

Commit d496287

Browse files
author
yuhaixin.hx
committed
remove allow_fail test flag
1 parent 6b8c33d commit d496287

File tree

8 files changed

+15
-93
lines changed

8 files changed

+15
-93
lines changed

test/src/console.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ pub struct ConsoleTestState {
4747
pub passed: usize,
4848
pub failed: usize,
4949
pub ignored: usize,
50-
pub allowed_fail: usize,
5150
pub filtered_out: usize,
5251
pub measured: usize,
5352
pub exec_time: Option<TestSuiteExecTime>,
@@ -71,7 +70,6 @@ impl ConsoleTestState {
7170
passed: 0,
7271
failed: 0,
7372
ignored: 0,
74-
allowed_fail: 0,
7573
filtered_out: 0,
7674
measured: 0,
7775
exec_time: None,
@@ -112,7 +110,6 @@ impl ConsoleTestState {
112110
TestResult::TrFailed => "failed".to_owned(),
113111
TestResult::TrFailedMsg(ref msg) => format!("failed: {}", msg),
114112
TestResult::TrIgnored => "ignored".to_owned(),
115-
TestResult::TrAllowedFail => "failed (allowed)".to_owned(),
116113
TestResult::TrBench(ref bs) => fmt_bench_samples(bs),
117114
TestResult::TrTimedFail => "failed (time limit exceeded)".to_owned(),
118115
},
@@ -126,7 +123,7 @@ impl ConsoleTestState {
126123
}
127124

128125
fn current_test_count(&self) -> usize {
129-
self.passed + self.failed + self.ignored + self.measured + self.allowed_fail
126+
self.passed + self.failed + self.ignored + self.measured
130127
}
131128
}
132129

@@ -191,7 +188,6 @@ fn handle_test_result(st: &mut ConsoleTestState, completed_test: CompletedTest)
191188
st.not_failures.push((test, stdout));
192189
}
193190
TestResult::TrIgnored => st.ignored += 1,
194-
TestResult::TrAllowedFail => st.allowed_fail += 1,
195191
TestResult::TrBench(bs) => {
196192
st.metrics.insert_metric(
197193
test.name.as_slice(),

test/src/formatters/json.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,6 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
124124
self.write_event("test", desc.name.as_slice(), "ignored", exec_time, stdout, None)
125125
}
126126

127-
TestResult::TrAllowedFail => self.write_event(
128-
"test",
129-
desc.name.as_slice(),
130-
"allowed_failure",
131-
exec_time,
132-
stdout,
133-
None,
134-
),
135-
136127
TestResult::TrBench(ref bs) => {
137128
let median = bs.ns_iter_summ.median as usize;
138129
let deviation = (bs.ns_iter_summ.max - bs.ns_iter_summ.min) as usize;
@@ -172,14 +163,12 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
172163
\"event\": \"{}\", \
173164
\"passed\": {}, \
174165
\"failed\": {}, \
175-
\"allowed_fail\": {}, \
176166
\"ignored\": {}, \
177167
\"measured\": {}, \
178168
\"filtered_out\": {}",
179169
if state.failed == 0 { "ok" } else { "failed" },
180170
state.passed,
181-
state.failed + state.allowed_fail,
182-
state.allowed_fail,
171+
state.failed,
183172
state.ignored,
184173
state.measured,
185174
state.filtered_out,

test/src/formatters/junit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> {
122122
))?;
123123
}
124124

125-
TestResult::TrOk | TestResult::TrAllowedFail => {
125+
TestResult::TrOk => {
126126
self.write_message(&*format!(
127127
"<testcase classname=\"{}\" \
128128
name=\"{}\" time=\"{}\"/>",

test/src/formatters/pretty.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ impl<T: Write> PrettyFormatter<T> {
4949
self.write_short_result("ignored", term::color::YELLOW)
5050
}
5151

52-
pub fn write_allowed_fail(&mut self) -> io::Result<()> {
53-
self.write_short_result("FAILED (allowed)", term::color::YELLOW)
54-
}
55-
5652
pub fn write_time_failed(&mut self) -> io::Result<()> {
5753
self.write_short_result("FAILED (time limit exceeded)", term::color::RED)
5854
}
@@ -219,7 +215,6 @@ impl<T: Write> OutputFormatter for PrettyFormatter<T> {
219215
TestResult::TrOk => self.write_ok()?,
220216
TestResult::TrFailed | TestResult::TrFailedMsg(_) => self.write_failed()?,
221217
TestResult::TrIgnored => self.write_ignored()?,
222-
TestResult::TrAllowedFail => self.write_allowed_fail()?,
223218
TestResult::TrBench(ref bs) => {
224219
self.write_bench()?;
225220
self.write_plain(&format!(": {}", fmt_bench_samples(bs)))?;
@@ -263,22 +258,10 @@ impl<T: Write> OutputFormatter for PrettyFormatter<T> {
263258
self.write_pretty("FAILED", term::color::RED)?;
264259
}
265260

266-
let s = if state.allowed_fail > 0 {
267-
format!(
268-
". {} passed; {} failed ({} allowed); {} ignored; {} measured; {} filtered out",
269-
state.passed,
270-
state.failed + state.allowed_fail,
271-
state.allowed_fail,
272-
state.ignored,
273-
state.measured,
274-
state.filtered_out
275-
)
276-
} else {
277-
format!(
278-
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
279-
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
280-
)
281-
};
261+
let s = format!(
262+
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
263+
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
264+
);
282265

283266
self.write_plain(&s)?;
284267

test/src/formatters/terse.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ impl<T: Write> TerseFormatter<T> {
5454
self.write_short_result("i", term::color::YELLOW)
5555
}
5656

57-
pub fn write_allowed_fail(&mut self) -> io::Result<()> {
58-
self.write_short_result("a", term::color::YELLOW)
59-
}
60-
6157
pub fn write_bench(&mut self) -> io::Result<()> {
6258
self.write_pretty("bench", term::color::CYAN)
6359
}
@@ -207,7 +203,6 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> {
207203
self.write_failed()
208204
}
209205
TestResult::TrIgnored => self.write_ignored(),
210-
TestResult::TrAllowedFail => self.write_allowed_fail(),
211206
TestResult::TrBench(ref bs) => {
212207
if self.is_multithreaded {
213208
self.write_test_name(desc)?;
@@ -244,22 +239,10 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> {
244239
self.write_pretty("FAILED", term::color::RED)?;
245240
}
246241

247-
let s = if state.allowed_fail > 0 {
248-
format!(
249-
". {} passed; {} failed ({} allowed); {} ignored; {} measured; {} filtered out",
250-
state.passed,
251-
state.failed + state.allowed_fail,
252-
state.allowed_fail,
253-
state.ignored,
254-
state.measured,
255-
state.filtered_out
256-
)
257-
} else {
258-
format!(
259-
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
260-
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
261-
)
262-
};
242+
let s = format!(
243+
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
244+
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
245+
);
263246

264247
self.write_plain(&s)?;
265248

test/src/test_result.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub enum TestResult {
1919
TrFailed,
2020
TrFailedMsg(String),
2121
TrIgnored,
22-
TrAllowedFail,
2322
TrBench(BenchSamples),
2423
TrTimedFail,
2524
}
@@ -42,8 +41,6 @@ pub fn calc_result<'a>(
4241

4342
if maybe_panic_str.map(|e| e.contains(msg)).unwrap_or(false) {
4443
TestResult::TrOk
45-
} else if desc.allow_fail {
46-
TestResult::TrAllowedFail
4744
} else if let Some(panic_str) = maybe_panic_str {
4845
TestResult::TrFailedMsg(format!(
4946
r#"panic did not contain expected string
@@ -64,7 +61,6 @@ pub fn calc_result<'a>(
6461
(&ShouldPanic::Yes, Ok(())) | (&ShouldPanic::YesWithMessage(_), Ok(())) => {
6562
TestResult::TrFailedMsg("test did not panic as expected".to_string())
6663
}
67-
_ if desc.allow_fail => TestResult::TrAllowedFail,
6864
_ => TestResult::TrFailed,
6965
};
7066

@@ -90,11 +86,10 @@ pub fn get_result_from_exit_code(
9086
time_opts: &Option<time::TestTimeOptions>,
9187
exec_time: &Option<time::TestExecTime>,
9288
) -> TestResult {
93-
let result = match (desc.allow_fail, code) {
94-
(_, TR_OK) => TestResult::TrOk,
95-
(true, TR_FAILED) => TestResult::TrAllowedFail,
96-
(false, TR_FAILED) => TestResult::TrFailed,
97-
(_, _) => TestResult::TrFailedMsg(format!("got unexpected return code {}", code)),
89+
let result = match code {
90+
TR_OK => TestResult::TrOk,
91+
TR_FAILED => TestResult::TrFailed,
92+
_ => TestResult::TrFailedMsg(format!("got unexpected return code {}", code)),
9893
};
9994

10095
// If test is already failed (or allowed to fail), do not change the result.

test/src/tests.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ fn one_ignored_one_unignored_test() -> Vec<TestDescAndFn> {
6262
name: StaticTestName("1"),
6363
ignore: true,
6464
should_panic: ShouldPanic::No,
65-
allow_fail: false,
6665
compile_fail: false,
6766
no_run: false,
6867
test_type: TestType::Unknown,
@@ -74,7 +73,6 @@ fn one_ignored_one_unignored_test() -> Vec<TestDescAndFn> {
7473
name: StaticTestName("2"),
7574
ignore: false,
7675
should_panic: ShouldPanic::No,
77-
allow_fail: false,
7876
compile_fail: false,
7977
no_run: false,
8078
test_type: TestType::Unknown,
@@ -94,7 +92,6 @@ pub fn do_not_run_ignored_tests() {
9492
name: StaticTestName("whatever"),
9593
ignore: true,
9694
should_panic: ShouldPanic::No,
97-
allow_fail: false,
9895
compile_fail: false,
9996
no_run: false,
10097
test_type: TestType::Unknown,
@@ -115,7 +112,6 @@ pub fn ignored_tests_result_in_ignored() {
115112
name: StaticTestName("whatever"),
116113
ignore: true,
117114
should_panic: ShouldPanic::No,
118-
allow_fail: false,
119115
compile_fail: false,
120116
no_run: false,
121117
test_type: TestType::Unknown,
@@ -140,7 +136,6 @@ fn test_should_panic() {
140136
name: StaticTestName("whatever"),
141137
ignore: false,
142138
should_panic: ShouldPanic::Yes,
143-
allow_fail: false,
144139
compile_fail: false,
145140
no_run: false,
146141
test_type: TestType::Unknown,
@@ -165,7 +160,6 @@ fn test_should_panic_good_message() {
165160
name: StaticTestName("whatever"),
166161
ignore: false,
167162
should_panic: ShouldPanic::YesWithMessage("error message"),
168-
allow_fail: false,
169163
compile_fail: false,
170164
no_run: false,
171165
test_type: TestType::Unknown,
@@ -195,7 +189,6 @@ fn test_should_panic_bad_message() {
195189
name: StaticTestName("whatever"),
196190
ignore: false,
197191
should_panic: ShouldPanic::YesWithMessage(expected),
198-
allow_fail: false,
199192
compile_fail: false,
200193
no_run: false,
201194
test_type: TestType::Unknown,
@@ -229,7 +222,6 @@ fn test_should_panic_non_string_message_type() {
229222
name: StaticTestName("whatever"),
230223
ignore: false,
231224
should_panic: ShouldPanic::YesWithMessage(expected),
232-
allow_fail: false,
233225
compile_fail: false,
234226
no_run: false,
235227
test_type: TestType::Unknown,
@@ -255,7 +247,6 @@ fn test_should_panic_but_succeeds() {
255247
name: StaticTestName("whatever"),
256248
ignore: false,
257249
should_panic,
258-
allow_fail: false,
259250
compile_fail: false,
260251
no_run: false,
261252
test_type: TestType::Unknown,
@@ -289,7 +280,6 @@ fn report_time_test_template(report_time: bool) -> Option<TestExecTime> {
289280
name: StaticTestName("whatever"),
290281
ignore: false,
291282
should_panic: ShouldPanic::No,
292-
allow_fail: false,
293283
compile_fail: false,
294284
no_run: false,
295285
test_type: TestType::Unknown,
@@ -324,7 +314,6 @@ fn time_test_failure_template(test_type: TestType) -> TestResult {
324314
name: StaticTestName("whatever"),
325315
ignore: false,
326316
should_panic: ShouldPanic::No,
327-
allow_fail: false,
328317
compile_fail: false,
329318
no_run: false,
330319
test_type,
@@ -363,7 +352,6 @@ fn typed_test_desc(test_type: TestType) -> TestDesc {
363352
name: StaticTestName("whatever"),
364353
ignore: false,
365354
should_panic: ShouldPanic::No,
366-
allow_fail: false,
367355
compile_fail: false,
368356
no_run: false,
369357
test_type,
@@ -476,7 +464,6 @@ pub fn exclude_should_panic_option() {
476464
name: StaticTestName("3"),
477465
ignore: false,
478466
should_panic: ShouldPanic::Yes,
479-
allow_fail: false,
480467
compile_fail: false,
481468
no_run: false,
482469
test_type: TestType::Unknown,
@@ -500,7 +487,6 @@ pub fn exact_filter_match() {
500487
name: StaticTestName(name),
501488
ignore: false,
502489
should_panic: ShouldPanic::No,
503-
allow_fail: false,
504490
compile_fail: false,
505491
no_run: false,
506492
test_type: TestType::Unknown,
@@ -589,7 +575,6 @@ fn sample_tests() -> Vec<TestDescAndFn> {
589575
name: DynTestName((*name).clone()),
590576
ignore: false,
591577
should_panic: ShouldPanic::No,
592-
allow_fail: false,
593578
compile_fail: false,
594579
no_run: false,
595580
test_type: TestType::Unknown,
@@ -740,7 +725,6 @@ pub fn test_bench_no_iter() {
740725
name: StaticTestName("f"),
741726
ignore: false,
742727
should_panic: ShouldPanic::No,
743-
allow_fail: false,
744728
compile_fail: false,
745729
no_run: false,
746730
test_type: TestType::Unknown,
@@ -762,7 +746,6 @@ pub fn test_bench_iter() {
762746
name: StaticTestName("f"),
763747
ignore: false,
764748
should_panic: ShouldPanic::No,
765-
allow_fail: false,
766749
compile_fail: false,
767750
no_run: false,
768751
test_type: TestType::Unknown,
@@ -778,7 +761,6 @@ fn should_sort_failures_before_printing_them() {
778761
name: StaticTestName("a"),
779762
ignore: false,
780763
should_panic: ShouldPanic::No,
781-
allow_fail: false,
782764
compile_fail: false,
783765
no_run: false,
784766
test_type: TestType::Unknown,
@@ -788,7 +770,6 @@ fn should_sort_failures_before_printing_them() {
788770
name: StaticTestName("b"),
789771
ignore: false,
790772
should_panic: ShouldPanic::No,
791-
allow_fail: false,
792773
compile_fail: false,
793774
no_run: false,
794775
test_type: TestType::Unknown,
@@ -802,7 +783,6 @@ fn should_sort_failures_before_printing_them() {
802783
passed: 0,
803784
failed: 0,
804785
ignored: 0,
805-
allowed_fail: 0,
806786
filtered_out: 0,
807787
measured: 0,
808788
exec_time: None,

test/src/types.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ pub struct TestDesc {
118118
pub name: TestName,
119119
pub ignore: bool,
120120
pub should_panic: options::ShouldPanic,
121-
pub allow_fail: bool,
122121
pub compile_fail: bool,
123122
pub no_run: bool,
124123
pub test_type: TestType,
@@ -150,9 +149,6 @@ impl TestDesc {
150149
}
151150
options::ShouldPanic::No => {}
152151
}
153-
if self.allow_fail {
154-
return Some("allow fail");
155-
}
156152
if self.compile_fail {
157153
return Some("compile fail");
158154
}

0 commit comments

Comments
 (0)