mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Rollup merge of #106769 - lenko-d:libtest-print_why_a_test_was_ignored_if_its_the_only_test_specified, r=Mark-Simulacrum
libtest: Print why a test was ignored if it's the only test specified. Fixes [#106659](https://github.com/rust-lang/rust/issues/106659) Needed by [106763](https://github.com/rust-lang/rust/pull/106763)
This commit is contained in:
commit
192eecd53a
@ -53,6 +53,7 @@ pub struct ConsoleTestState {
|
||||
pub metrics: MetricMap,
|
||||
pub failures: Vec<(TestDesc, Vec<u8>)>,
|
||||
pub not_failures: Vec<(TestDesc, Vec<u8>)>,
|
||||
pub ignores: Vec<(TestDesc, Vec<u8>)>,
|
||||
pub time_failures: Vec<(TestDesc, Vec<u8>)>,
|
||||
pub options: Options,
|
||||
}
|
||||
@ -76,6 +77,7 @@ impl ConsoleTestState {
|
||||
metrics: MetricMap::new(),
|
||||
failures: Vec::new(),
|
||||
not_failures: Vec::new(),
|
||||
ignores: Vec::new(),
|
||||
time_failures: Vec::new(),
|
||||
options: opts.options,
|
||||
})
|
||||
@ -194,7 +196,10 @@ fn handle_test_result(st: &mut ConsoleTestState, completed_test: CompletedTest)
|
||||
st.passed += 1;
|
||||
st.not_failures.push((test, stdout));
|
||||
}
|
||||
TestResult::TrIgnored => st.ignored += 1,
|
||||
TestResult::TrIgnored => {
|
||||
st.ignored += 1;
|
||||
st.ignores.push((test, stdout));
|
||||
}
|
||||
TestResult::TrBench(bs) => {
|
||||
st.metrics.insert_metric(
|
||||
test.name.as_slice(),
|
||||
|
@ -254,6 +254,15 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> {
|
||||
|
||||
self.write_plain("\n\n")?;
|
||||
|
||||
// Custom handling of cases where there is only 1 test to execute and that test was ignored.
|
||||
// We want to show more detailed information(why was the test ignored) for investigation purposes.
|
||||
if self.total_test_count == 1 && state.ignores.len() == 1 {
|
||||
let test_desc = &state.ignores[0].0;
|
||||
if let Some(im) = test_desc.ignore_message {
|
||||
self.write_plain(format!("test: {}, ignore_message: {}\n\n", test_desc.name, im))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(success)
|
||||
}
|
||||
}
|
||||
|
@ -790,6 +790,7 @@ fn should_sort_failures_before_printing_them() {
|
||||
failures: vec![(test_b, Vec::new()), (test_a, Vec::new())],
|
||||
options: Options::new(),
|
||||
not_failures: Vec::new(),
|
||||
ignores: Vec::new(),
|
||||
time_failures: Vec::new(),
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user