Change test skipping logic a little, separate feature-based and function-based skipping
This commit is contained in:
committed by
Amanieu d'Antras
parent
cc6855e1e9
commit
b3a7ba4607
@@ -51,7 +51,6 @@ pub fn simd_test(
|
||||
let target = env::var("TARGET").expect(
|
||||
"TARGET environment variable should be set for rustc (e.g. TARGET=x86_64-apple-darwin cargo test)"
|
||||
);
|
||||
let mut force_test = false;
|
||||
let macro_test = match target
|
||||
.split('-')
|
||||
.next()
|
||||
@@ -63,27 +62,29 @@ pub fn simd_test(
|
||||
maybe_riscv if maybe_riscv.starts_with("riscv") => "is_riscv_feature_detected",
|
||||
"powerpc" | "powerpcle" => "is_powerpc_feature_detected",
|
||||
"powerpc64" | "powerpc64le" => "is_powerpc64_feature_detected",
|
||||
"mips" | "mipsel" | "mipsisa32r6" | "mipsisa32r6el" => {
|
||||
// FIXME:
|
||||
// On MIPS CI run-time feature detection always returns false due
|
||||
// to this qemu bug: https://bugs.launchpad.net/qemu/+bug/1754372
|
||||
//
|
||||
// This is a workaround to force the MIPS tests to always run on
|
||||
// CI.
|
||||
force_test = true;
|
||||
"is_mips_feature_detected"
|
||||
}
|
||||
"mips64" | "mips64el" | "mipsisa64r6" | "mipsisa64r6el" => {
|
||||
// FIXME: see above
|
||||
force_test = true;
|
||||
"is_mips64_feature_detected"
|
||||
}
|
||||
"loongarch64" => "is_loongarch_feature_detected",
|
||||
"s390x" => "is_s390x_feature_detected",
|
||||
t => panic!("unknown target: {t}"),
|
||||
};
|
||||
let macro_test = Ident::new(macro_test, Span::call_site());
|
||||
|
||||
let skipped_functions = env::var("STDARCH_TEST_SKIP_FUNCTION").unwrap_or_default();
|
||||
let skipped_features = env::var("STDARCH_TEST_SKIP_FEATURE").unwrap_or_default();
|
||||
|
||||
let mut name_str = &*name.to_string();
|
||||
if name_str.starts_with("test_") {
|
||||
name_str = &name_str[5..];
|
||||
}
|
||||
|
||||
let skip_this = skipped_functions
|
||||
.split(',')
|
||||
.map(str::trim)
|
||||
.any(|s| s == name_str)
|
||||
|| skipped_features
|
||||
.split(',')
|
||||
.map(str::trim)
|
||||
.any(|s| target_features.iter().any(|feature| s == feature));
|
||||
|
||||
let mut detect_missing_features = TokenStream::new();
|
||||
for feature in target_features {
|
||||
let q = quote_spanned! {
|
||||
@@ -95,8 +96,7 @@ pub fn simd_test(
|
||||
q.to_tokens(&mut detect_missing_features);
|
||||
}
|
||||
|
||||
let test_norun = std::env::var("STDSIMD_TEST_NORUN").is_ok();
|
||||
let maybe_ignore = if test_norun {
|
||||
let maybe_ignore = if skip_this {
|
||||
quote! { #[ignore] }
|
||||
} else {
|
||||
TokenStream::new()
|
||||
@@ -111,7 +111,7 @@ pub fn simd_test(
|
||||
fn #name() {
|
||||
let mut missing_features = ::std::vec::Vec::new();
|
||||
#detect_missing_features
|
||||
if #force_test || missing_features.is_empty() {
|
||||
if missing_features.is_empty() {
|
||||
let v = unsafe { #name() };
|
||||
return v;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user