Skip to content

Commit 76e9f77

Browse files
committed
Change test skipping logic a little, separate feature-based and function-based skipping
+ Simplify optimization detection logic in `assert_instr_macro`
1 parent 50919ba commit 76e9f77

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

ci/run.sh

+1-4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ echo "FEATURES=${FEATURES}"
6363
echo "OBJDUMP=${OBJDUMP}"
6464
echo "STDARCH_DISABLE_ASSERT_INSTR=${STDARCH_DISABLE_ASSERT_INSTR}"
6565
echo "STDARCH_TEST_EVERYTHING=${STDARCH_TEST_EVERYTHING}"
66+
echo "STDARCH_TEST_SKIP_FEATURE=${STDARCH_TEST_SKIP_FEATURE}"
6667
echo "PROFILE=${PROFILE}"
6768

6869
cargo_test() {
@@ -86,10 +87,6 @@ cargo_test() {
8687
cmd="$cmd --skip test_vec_lde_u16 --skip test_vec_lde_u32"
8788
;;
8889
esac
89-
90-
if [ "$SKIP_TESTS" != "" ]; then
91-
cmd="$cmd --skip "$SKIP_TESTS
92-
fi
9390
$cmd
9491
}
9592

crates/assert-instr-macro/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ test = false
1212
proc-macro2 = "1.0"
1313
quote = "1.0"
1414
syn = { version = "2.0", features = ["full"] }
15+
16+
[lints.rust]
17+
unexpected_cfgs = {level = "warn", check-cfg = ['cfg(optimized)'] }

crates/assert-instr-macro/build.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use std::env;
22

33
fn main() {
4-
println!("cargo:rerun-if-changed=build.rs");
5-
println!("cargo::rustc-check-cfg=cfg(optimized)");
64
let opt_level = env::var("OPT_LEVEL")
75
.ok()
86
.and_then(|s| s.parse().ok())
97
.unwrap_or(0);
10-
let profile = env::var("PROFILE").unwrap_or_default();
11-
if profile == "release" || opt_level >= 2 {
8+
9+
if opt_level >= 2 {
1210
println!("cargo:rustc-cfg=optimized");
1311
}
1412
}

crates/simd-test-macro/src/lib.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pub fn simd_test(
5151
let target = env::var("TARGET").expect(
5252
"TARGET environment variable should be set for rustc (e.g. TARGET=x86_64-apple-darwin cargo test)"
5353
);
54-
let mut force_test = false;
5554
let macro_test = match target
5655
.split('-')
5756
.next()
@@ -63,27 +62,29 @@ pub fn simd_test(
6362
maybe_riscv if maybe_riscv.starts_with("riscv") => "is_riscv_feature_detected",
6463
"powerpc" | "powerpcle" => "is_powerpc_feature_detected",
6564
"powerpc64" | "powerpc64le" => "is_powerpc64_feature_detected",
66-
"mips" | "mipsel" | "mipsisa32r6" | "mipsisa32r6el" => {
67-
// FIXME:
68-
// On MIPS CI run-time feature detection always returns false due
69-
// to this qemu bug: https://bugs.launchpad.net/qemu/+bug/1754372
70-
//
71-
// This is a workaround to force the MIPS tests to always run on
72-
// CI.
73-
force_test = true;
74-
"is_mips_feature_detected"
75-
}
76-
"mips64" | "mips64el" | "mipsisa64r6" | "mipsisa64r6el" => {
77-
// FIXME: see above
78-
force_test = true;
79-
"is_mips64_feature_detected"
80-
}
8165
"loongarch64" => "is_loongarch_feature_detected",
8266
"s390x" => "is_s390x_feature_detected",
8367
t => panic!("unknown target: {t}"),
8468
};
8569
let macro_test = Ident::new(macro_test, Span::call_site());
8670

71+
let skipped_functions = env::var("STDARCH_TEST_SKIP_FUNCTION").unwrap_or_default();
72+
let skipped_features = env::var("STDARCH_TEST_SKIP_FEATURE").unwrap_or_default();
73+
74+
let mut name_str = &*name.to_string();
75+
if name_str.starts_with("test_") {
76+
name_str = &name_str[5..];
77+
}
78+
79+
let skip_this = skipped_functions
80+
.split(',')
81+
.map(str::trim)
82+
.any(|s| s == name_str)
83+
&& skipped_features
84+
.split(',')
85+
.map(str::trim)
86+
.any(|s| target_features.iter().any(|feature| s == feature));
87+
8788
let mut detect_missing_features = TokenStream::new();
8889
for feature in target_features {
8990
let q = quote_spanned! {
@@ -95,8 +96,7 @@ pub fn simd_test(
9596
q.to_tokens(&mut detect_missing_features);
9697
}
9798

98-
let test_norun = std::env::var("STDSIMD_TEST_NORUN").is_ok();
99-
let maybe_ignore = if test_norun {
99+
let maybe_ignore = if skip_this {
100100
quote! { #[ignore] }
101101
} else {
102102
TokenStream::new()
@@ -111,7 +111,7 @@ pub fn simd_test(
111111
fn #name() {
112112
let mut missing_features = ::std::vec::Vec::new();
113113
#detect_missing_features
114-
if #force_test || missing_features.is_empty() {
114+
if missing_features.is_empty() {
115115
let v = unsafe { #name() };
116116
return v;
117117
} else {

0 commit comments

Comments
 (0)