Skip to content

Commit

Permalink
Rollup merge of rust-lang#93416 - name1e5s:chore/remove_allow_fail, r…
Browse files Browse the repository at this point in the history
…=m-ou-se

remove `allow_fail` test flag

close rust-lang#93345
  • Loading branch information
m-ou-se committed Feb 7, 2022
2 parents 4445a8f + 0b8c9fb commit 252ff5e
Show file tree
Hide file tree
Showing 25 changed files with 79 additions and 270 deletions.
9 changes: 0 additions & 9 deletions compiler/rustc_builtin_macros/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,6 @@ pub fn expand_test_or_bench(
"ignore",
cx.expr_bool(sp, should_ignore(&cx.sess, &item)),
),
// allow_fail: true | false
field(
"allow_fail",
cx.expr_bool(sp, should_fail(&cx.sess, &item)),
),
// compile_fail: true | false
field("compile_fail", cx.expr_bool(sp, false)),
// no_run: true | false
Expand Down Expand Up @@ -359,10 +354,6 @@ fn should_ignore(sess: &Session, i: &ast::Item) -> bool {
sess.contains_name(&i.attrs, sym::ignore)
}

fn should_fail(sess: &Session, i: &ast::Item) -> bool {
sess.contains_name(&i.attrs, sym::allow_fail)
}

fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
match cx.sess.find_by_name(&i.attrs, sym::should_panic) {
Some(attr) => {
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ declare_features! (
(incomplete, adt_const_params, "1.56.0", Some(44580), None),
/// Allows defining an `#[alloc_error_handler]`.
(active, alloc_error_handler, "1.29.0", Some(51540), None),
/// Allows a test to fail without failing the whole suite.
(active, allow_fail, "1.19.0", Some(46488), None),
/// Allows explicit discriminants on non-unit enum variants.
(active, arbitrary_enum_discriminant, "1.37.0", Some(60553), None),
/// Allows trait methods with arbitrary self types.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
},

// Testing:
gated!(allow_fail, Normal, template!(Word), WarnFollowing, experimental!(allow_fail)),
gated!(
test_runner, CrateLevel, template!(List: "path"), ErrorFollowing, custom_test_frameworks,
"custom test frameworks are an unstable feature",
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ declare_features! (
(removed, advanced_slice_patterns, "1.0.0", Some(62254), None,
Some("merged into `#![feature(slice_patterns)]`")),
(removed, allocator, "1.0.0", None, None, None),
/// Allows a test to fail without failing the whole suite.
(removed, allow_fail, "1.19.0", Some(46488), None, Some("removed due to no clear use cases")),
(removed, await_macro, "1.38.0", Some(50547), None,
Some("subsumed by `.await` syntax")),
/// Allows comparing raw pointers during const eval.
Expand Down
6 changes: 1 addition & 5 deletions library/test/src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pub struct ConsoleTestState {
pub passed: usize,
pub failed: usize,
pub ignored: usize,
pub allowed_fail: usize,
pub filtered_out: usize,
pub measured: usize,
pub exec_time: Option<TestSuiteExecTime>,
Expand All @@ -71,7 +70,6 @@ impl ConsoleTestState {
passed: 0,
failed: 0,
ignored: 0,
allowed_fail: 0,
filtered_out: 0,
measured: 0,
exec_time: None,
Expand Down Expand Up @@ -112,7 +110,6 @@ impl ConsoleTestState {
TestResult::TrFailed => "failed".to_owned(),
TestResult::TrFailedMsg(ref msg) => format!("failed: {}", msg),
TestResult::TrIgnored => "ignored".to_owned(),
TestResult::TrAllowedFail => "failed (allowed)".to_owned(),
TestResult::TrBench(ref bs) => fmt_bench_samples(bs),
TestResult::TrTimedFail => "failed (time limit exceeded)".to_owned(),
},
Expand All @@ -126,7 +123,7 @@ impl ConsoleTestState {
}

fn current_test_count(&self) -> usize {
self.passed + self.failed + self.ignored + self.measured + self.allowed_fail
self.passed + self.failed + self.ignored + self.measured
}
}

Expand Down Expand Up @@ -191,7 +188,6 @@ fn handle_test_result(st: &mut ConsoleTestState, completed_test: CompletedTest)
st.not_failures.push((test, stdout));
}
TestResult::TrIgnored => st.ignored += 1,
TestResult::TrAllowedFail => st.allowed_fail += 1,
TestResult::TrBench(bs) => {
st.metrics.insert_metric(
test.name.as_slice(),
Expand Down
13 changes: 1 addition & 12 deletions library/test/src/formatters/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,6 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
self.write_event("test", desc.name.as_slice(), "ignored", exec_time, stdout, None)
}

TestResult::TrAllowedFail => self.write_event(
"test",
desc.name.as_slice(),
"allowed_failure",
exec_time,
stdout,
None,
),

TestResult::TrBench(ref bs) => {
let median = bs.ns_iter_summ.median as usize;
let deviation = (bs.ns_iter_summ.max - bs.ns_iter_summ.min) as usize;
Expand Down Expand Up @@ -172,14 +163,12 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
\"event\": \"{}\", \
\"passed\": {}, \
\"failed\": {}, \
\"allowed_fail\": {}, \
\"ignored\": {}, \
\"measured\": {}, \
\"filtered_out\": {}",
if state.failed == 0 { "ok" } else { "failed" },
state.passed,
state.failed + state.allowed_fail,
state.allowed_fail,
state.failed,
state.ignored,
state.measured,
state.filtered_out,
Expand Down
2 changes: 1 addition & 1 deletion library/test/src/formatters/junit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> {
))?;
}

TestResult::TrOk | TestResult::TrAllowedFail => {
TestResult::TrOk => {
self.write_message(&*format!(
"<testcase classname=\"{}\" \
name=\"{}\" time=\"{}\"/>",
Expand Down
25 changes: 4 additions & 21 deletions library/test/src/formatters/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ impl<T: Write> PrettyFormatter<T> {
self.write_short_result("ignored", term::color::YELLOW)
}

pub fn write_allowed_fail(&mut self) -> io::Result<()> {
self.write_short_result("FAILED (allowed)", term::color::YELLOW)
}

pub fn write_time_failed(&mut self) -> io::Result<()> {
self.write_short_result("FAILED (time limit exceeded)", term::color::RED)
}
Expand Down Expand Up @@ -219,7 +215,6 @@ impl<T: Write> OutputFormatter for PrettyFormatter<T> {
TestResult::TrOk => self.write_ok()?,
TestResult::TrFailed | TestResult::TrFailedMsg(_) => self.write_failed()?,
TestResult::TrIgnored => self.write_ignored()?,
TestResult::TrAllowedFail => self.write_allowed_fail()?,
TestResult::TrBench(ref bs) => {
self.write_bench()?;
self.write_plain(&format!(": {}", fmt_bench_samples(bs)))?;
Expand Down Expand Up @@ -263,22 +258,10 @@ impl<T: Write> OutputFormatter for PrettyFormatter<T> {
self.write_pretty("FAILED", term::color::RED)?;
}

let s = if state.allowed_fail > 0 {
format!(
". {} passed; {} failed ({} allowed); {} ignored; {} measured; {} filtered out",
state.passed,
state.failed + state.allowed_fail,
state.allowed_fail,
state.ignored,
state.measured,
state.filtered_out
)
} else {
format!(
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
)
};
let s = format!(
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
);

self.write_plain(&s)?;

Expand Down
25 changes: 4 additions & 21 deletions library/test/src/formatters/terse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ impl<T: Write> TerseFormatter<T> {
self.write_short_result("i", term::color::YELLOW)
}

pub fn write_allowed_fail(&mut self) -> io::Result<()> {
self.write_short_result("a", term::color::YELLOW)
}

pub fn write_bench(&mut self) -> io::Result<()> {
self.write_pretty("bench", term::color::CYAN)
}
Expand Down Expand Up @@ -207,7 +203,6 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> {
self.write_failed()
}
TestResult::TrIgnored => self.write_ignored(),
TestResult::TrAllowedFail => self.write_allowed_fail(),
TestResult::TrBench(ref bs) => {
if self.is_multithreaded {
self.write_test_name(desc)?;
Expand Down Expand Up @@ -244,22 +239,10 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> {
self.write_pretty("FAILED", term::color::RED)?;
}

let s = if state.allowed_fail > 0 {
format!(
". {} passed; {} failed ({} allowed); {} ignored; {} measured; {} filtered out",
state.passed,
state.failed + state.allowed_fail,
state.allowed_fail,
state.ignored,
state.measured,
state.filtered_out
)
} else {
format!(
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
)
};
let s = format!(
". {} passed; {} failed; {} ignored; {} measured; {} filtered out",
state.passed, state.failed, state.ignored, state.measured, state.filtered_out
);

self.write_plain(&s)?;

Expand Down
13 changes: 4 additions & 9 deletions library/test/src/test_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub enum TestResult {
TrFailed,
TrFailedMsg(String),
TrIgnored,
TrAllowedFail,
TrBench(BenchSamples),
TrTimedFail,
}
Expand All @@ -42,8 +41,6 @@ pub fn calc_result<'a>(

if maybe_panic_str.map(|e| e.contains(msg)).unwrap_or(false) {
TestResult::TrOk
} else if desc.allow_fail {
TestResult::TrAllowedFail
} else if let Some(panic_str) = maybe_panic_str {
TestResult::TrFailedMsg(format!(
r#"panic did not contain expected string
Expand All @@ -64,7 +61,6 @@ pub fn calc_result<'a>(
(&ShouldPanic::Yes, Ok(())) | (&ShouldPanic::YesWithMessage(_), Ok(())) => {
TestResult::TrFailedMsg("test did not panic as expected".to_string())
}
_ if desc.allow_fail => TestResult::TrAllowedFail,
_ => TestResult::TrFailed,
};

Expand All @@ -90,11 +86,10 @@ pub fn get_result_from_exit_code(
time_opts: &Option<time::TestTimeOptions>,
exec_time: &Option<time::TestExecTime>,
) -> TestResult {
let result = match (desc.allow_fail, code) {
(_, TR_OK) => TestResult::TrOk,
(true, TR_FAILED) => TestResult::TrAllowedFail,
(false, TR_FAILED) => TestResult::TrFailed,
(_, _) => TestResult::TrFailedMsg(format!("got unexpected return code {}", code)),
let result = match code {
TR_OK => TestResult::TrOk,
TR_FAILED => TestResult::TrFailed,
_ => TestResult::TrFailedMsg(format!("got unexpected return code {}", code)),
};

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

0 comments on commit 252ff5e

Please sign in to comment.