Skip to contentSkip to conversation

rust: pin-init: examples, tests: use `ignore` instead of conditionally compiling tests

PATCH Applied Benno Lossin 2 participants 3 messages Jun 5, 2025 – Jun 9, 2025

Subsystems (2)
lore
Share & tools
lore

Benno Lossin

author maintainer
#0 lore raw

PATCH 1/1 rust: pin-init: examples, tests: use `ignore` instead of conditionally compiling tests

Change #[cfg(cond)] to #[cfg_attr(not(cond), ignore)] on tests.

Ignoring tests instead of disabling them still makes them appear in the test list, but with ignored. It also still compiles the code in those cases.

Some tests still need to be ignore, because they use types that are not present when the condition is false. For example the condition is feature = std and then it uses std::thread::Thread.

---

Depends on https://lore.kernel.org/all/[email protected]

---
 rust/pin-init/examples/pthread_mutex.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
rust/pin-init/examples/pthread_mutex.rs +2 -1
index 6c4d18238956..49b004c8c137 100644
@@ -139,7 +139,8 @@ fn deref_mut(&mut self) -> &mut Self::Target {
     }
 }
 
-#[cfg_attr(all(test, not(miri)), test)]
+#[cfg_attr(test, test)]
+#[cfg_attr(all(test, miri), ignore)]
 fn main() {
     #[cfg(all(any(feature = "std", feature = "alloc"), not(windows)))]
     {

base-commit: ae8b3a83fb9de394f609035041cd7a668fda2ab3
prerequisite-patch-id: 8d7ade67c2e5189bf8a2c91253d925e25744cba5
prerequisite-patch-id: 0ebbd4a86bebeff23257870db92a1b0fe017c481
prerequisite-patch-id: 1437fc7adeff6e13abd433594da923272b9388bf

Signature · 1 line
2.49.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Benno Lossin

Change #[cfg(cond)] to #[cfg_attr(not(cond), ignore)] on tests.

Ignoring tests instead of disabling them still makes them appear in the test list, but with ignored. It also still compiles the code in those cases.

Some tests still need to be ignore, because they use types that are not present when the condition is false. For example the condition is feature = std and then it uses std::thread::Thread.

Quoted 5 lines

---

Quoted 26 lines

Depends on https://lore.kernel.org/all/[email protected]

---
 rust/pin-init/examples/pthread_mutex.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
rust/pin-init/examples/pthread_mutex.rs +2 -1
index 6c4d18238956..49b004c8c137 100644
@@ -139,7 +139,8 @@ fn deref_mut(&mut self) -> &mut Self::Target {
     }
 }
 
-#[cfg_attr(all(test, not(miri)), test)]
+#[cfg_attr(test, test)]
+#[cfg_attr(all(test, miri), ignore)]
 fn main() {
     #[cfg(all(any(feature = "std", feature = "alloc"), not(windows)))]
     {

base-commit: ae8b3a83fb9de394f609035041cd7a668fda2ab3
prerequisite-patch-id: 8d7ade67c2e5189bf8a2c91253d925e25744cba5
prerequisite-patch-id: 0ebbd4a86bebeff23257870db92a1b0fe017c481
prerequisite-patch-id: 1437fc7adeff6e13abd433594da923272b9388bf

author maintainer Applied
#2 lore raw
In reply to Benno Lossin
Quoted 14 lines · Benno Lossin

Change #[cfg(cond)] to #[cfg_attr(not(cond), ignore)] on tests.

Ignoring tests instead of disabling them still makes them appear in the test list, but with ignored. It also still compiles the code in those cases.

Some tests still need to be ignore, because they use types that are not present when the condition is false. For example the condition is feature = std and then it uses std::thread::Thread.

Quoted 7 lines

---

Depends on https://lore.kernel.org/all/[email protected]

---
 rust/pin-init/examples/pthread_mutex.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Applied to pin-init-next -- thanks everyone!

---
Cheers,
Benno