Rollup merge of #106763 - lenko-d:106659-Print_why_a_test_was_ignored_if_its_the_only_test_specified, r=Mark-Simulacrum

print why a test was ignored if its the only test specified

Fixes [#106659](https://github.com/rust-lang/rust/issues/106659)
This commit is contained in:
Matthias Krüger 2023-01-29 20:03:35 +01:00 committed by GitHub
commit 94809b3345
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -926,7 +926,7 @@ pub fn make_test_description<R: Read>(
cfg: Option<&str>, cfg: Option<&str>,
) -> test::TestDesc { ) -> test::TestDesc {
let mut ignore = false; let mut ignore = false;
let ignore_message = None; let mut ignore_message = None;
let mut should_fail = false; let mut should_fail = false;
let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some(); let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some();
@ -966,41 +966,67 @@ pub fn make_test_description<R: Read>(
if revision.is_some() && revision != cfg { if revision.is_some() && revision != cfg {
return; return;
} }
macro_rules! reason {
($e:expr) => {
ignore |= match $e {
true => {
ignore_message = Some(stringify!($e));
true
}
false => ignore,
}
};
}
ignore = match config.parse_cfg_name_directive(ln, "ignore") { ignore = match config.parse_cfg_name_directive(ln, "ignore") {
ParsedNameDirective::Match => true, ParsedNameDirective::Match => {
ignore_message = Some("cfg -> ignore => Match");
true
}
ParsedNameDirective::NoMatch => ignore, ParsedNameDirective::NoMatch => ignore,
}; };
if config.has_cfg_prefix(ln, "only") { if config.has_cfg_prefix(ln, "only") {
ignore = match config.parse_cfg_name_directive(ln, "only") { ignore = match config.parse_cfg_name_directive(ln, "only") {
ParsedNameDirective::Match => ignore, ParsedNameDirective::Match => ignore,
ParsedNameDirective::NoMatch => true, ParsedNameDirective::NoMatch => {
ignore_message = Some("cfg -> only => NoMatch");
true
}
}; };
} }
ignore |= ignore_llvm(config, ln);
ignore |= reason!(ignore_llvm(config, ln));
config.run_clang_based_tests_with.is_none() && config.parse_needs_matching_clang(ln); reason!(
ignore |= !has_asm_support && config.parse_name_directive(ln, "needs-asm-support"); config.run_clang_based_tests_with.is_none() && config.parse_needs_matching_clang(ln)
ignore |= !rustc_has_profiler_support && config.parse_needs_profiler_support(ln); );
ignore |= !config.run_enabled() && config.parse_name_directive(ln, "needs-run-enabled"); reason!(!has_asm_support && config.parse_name_directive(ln, "needs-asm-support"));
ignore |= !rustc_has_sanitizer_support reason!(!rustc_has_profiler_support && config.parse_needs_profiler_support(ln));
&& config.parse_name_directive(ln, "needs-sanitizer-support"); reason!(!config.run_enabled() && config.parse_name_directive(ln, "needs-run-enabled"));
ignore |= !has_asan && config.parse_name_directive(ln, "needs-sanitizer-address"); reason!(
ignore |= !has_cfi && config.parse_name_directive(ln, "needs-sanitizer-cfi"); !rustc_has_sanitizer_support
ignore |= !has_kcfi && config.parse_name_directive(ln, "needs-sanitizer-kcfi"); && config.parse_name_directive(ln, "needs-sanitizer-support")
ignore |= !has_lsan && config.parse_name_directive(ln, "needs-sanitizer-leak"); );
ignore |= !has_msan && config.parse_name_directive(ln, "needs-sanitizer-memory"); reason!(!has_asan && config.parse_name_directive(ln, "needs-sanitizer-address"));
ignore |= !has_tsan && config.parse_name_directive(ln, "needs-sanitizer-thread"); reason!(!has_cfi && config.parse_name_directive(ln, "needs-sanitizer-cfi"));
ignore |= !has_hwasan && config.parse_name_directive(ln, "needs-sanitizer-hwaddress"); reason!(!has_kcfi && config.parse_name_directive(ln, "needs-sanitizer-kcfi"));
ignore |= !has_memtag && config.parse_name_directive(ln, "needs-sanitizer-memtag"); reason!(!has_lsan && config.parse_name_directive(ln, "needs-sanitizer-leak"));
ignore |= !has_shadow_call_stack reason!(!has_msan && config.parse_name_directive(ln, "needs-sanitizer-memory"));
&& config.parse_name_directive(ln, "needs-sanitizer-shadow-call-stack"); reason!(!has_tsan && config.parse_name_directive(ln, "needs-sanitizer-thread"));
ignore |= !config.can_unwind() && config.parse_name_directive(ln, "needs-unwind"); reason!(!has_hwasan && config.parse_name_directive(ln, "needs-sanitizer-hwaddress"));
ignore |= config.target == "wasm32-unknown-unknown" reason!(!has_memtag && config.parse_name_directive(ln, "needs-sanitizer-memtag"));
&& config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS); reason!(
ignore |= config.debugger == Some(Debugger::Cdb) && ignore_cdb(config, ln); !has_shadow_call_stack
ignore |= config.debugger == Some(Debugger::Gdb) && ignore_gdb(config, ln); && config.parse_name_directive(ln, "needs-sanitizer-shadow-call-stack")
ignore |= config.debugger == Some(Debugger::Lldb) && ignore_lldb(config, ln); );
ignore |= !has_rust_lld && config.parse_name_directive(ln, "needs-rust-lld"); reason!(!config.can_unwind() && config.parse_name_directive(ln, "needs-unwind"));
reason!(
config.target == "wasm32-unknown-unknown"
&& config.parse_name_directive(ln, directives::CHECK_RUN_RESULTS)
);
reason!(config.debugger == Some(Debugger::Cdb) && ignore_cdb(config, ln));
reason!(config.debugger == Some(Debugger::Gdb) && ignore_gdb(config, ln));
reason!(config.debugger == Some(Debugger::Lldb) && ignore_lldb(config, ln));
reason!(!has_rust_lld && config.parse_name_directive(ln, "needs-rust-lld"));
should_fail |= config.parse_name_directive(ln, "should-fail"); should_fail |= config.parse_name_directive(ln, "should-fail");
}); });