Skip to content

Commit 252ff5e

Browse files
authored
Rollup merge of #93416 - name1e5s:chore/remove_allow_fail, r=m-ou-se
remove `allow_fail` test flag close #93345
2 parents 4445a8f + 0b8c9fb commit 252ff5e

File tree

25 files changed

+79
-270
lines changed

25 files changed

+79
-270
lines changed

compiler/rustc_builtin_macros/src/test.rs

-9
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,6 @@ pub fn expand_test_or_bench(
252252
"ignore",
253253
cx.expr_bool(sp, should_ignore(&cx.sess, &item)),
254254
),
255-
// allow_fail: true | false
256-
field(
257-
"allow_fail",
258-
cx.expr_bool(sp, should_fail(&cx.sess, &item)),
259-
),
260255
// compile_fail: true | false
261256
field("compile_fail", cx.expr_bool(sp, false)),
262257
// no_run: true | false
@@ -359,10 +354,6 @@ fn should_ignore(sess: &Session, i: &ast::Item) -> bool {
359354
sess.contains_name(&i.attrs, sym::ignore)
360355
}
361356

362-
fn should_fail(sess: &Session, i: &ast::Item) -> bool {
363-
sess.contains_name(&i.attrs, sym::allow_fail)
364-
}
365-
366357
fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
367358
match cx.sess.find_by_name(&i.attrs, sym::should_panic) {
368359
Some(attr) => {

compiler/rustc_feature/src/active.rs

-2
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,6 @@ declare_features! (
277277
(incomplete, adt_const_params, "1.56.0", Some(44580), None),
278278
/// Allows defining an `#[alloc_error_handler]`.
279279
(active, alloc_error_handler, "1.29.0", Some(51540), None),
280-
/// Allows a test to fail without failing the whole suite.
281-
(active, allow_fail, "1.19.0", Some(46488), None),
282280
/// Allows explicit discriminants on non-unit enum variants.
283281
(active, arbitrary_enum_discriminant, "1.37.0", Some(60553), None),
284282
/// Allows trait methods with arbitrary self types.

compiler/rustc_feature/src/builtin_attrs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
403403
},
404404

405405
// Testing:
406-
gated!(allow_fail, Normal, template!(Word), WarnFollowing, experimental!(allow_fail)),
407406
gated!(
408407
test_runner, CrateLevel, template!(List: "path"), ErrorFollowing, custom_test_frameworks,
409408
"custom test frameworks are an unstable feature",

compiler/rustc_feature/src/removed.rs

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ declare_features! (
4848
(removed, advanced_slice_patterns, "1.0.0", Some(62254), None,
4949
Some("merged into `#![feature(slice_patterns)]`")),
5050
(removed, allocator, "1.0.0", None, None, None),
51+
/// Allows a test to fail without failing the whole suite.
52+
(removed, allow_fail, "1.19.0", Some(46488), None, Some("removed due to no clear use cases")),
5153
(removed, await_macro, "1.38.0", Some(50547), None,
5254
Some("subsumed by `.await` syntax")),
5355
/// Allows comparing raw pointers during const eval.

library/test/src/console.rs

+1-5
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(),

library/test/src/formatters/json.rs

+1-12
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,

library/test/src/formatters/junit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> {
121121
))?;
122122
}
123123

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

library/test/src/formatters/pretty.rs

+4-21
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

library/test/src/formatters/terse.rs

+4-21
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

library/test/src/test_result.rs

+4-9
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.

0 commit comments

Comments
 (0)