Skip to content

Commit a946826

Browse files
authored
Rollup merge of rust-lang#146439 - connortsui20:fix-sync-macro-attr, r=RalfJung
fix cfg for poison test macro Fixes test regression in rust-lang#144648 Continuation of rust-lang#146433 I think this is right? Not really sure how to test this myself to be honest. r? ``@RalfJung`` I'll also leave the improvement to the test macro for a separate PR (described [here](rust-lang#146433 (comment))) since I've never done something like that before. Though since this fixes all of the tests, it might not be necessary since anyone in the future will see the `cfg()` and not `cfg_attr()`?
2 parents b36175e + 6354c51 commit a946826

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

library/std/tests/sync/condvar.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ nonpoison_and_poison_unwrap_test!(
1717
}
1818
);
1919

20-
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
20+
#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] // No threads.
2121
nonpoison_and_poison_unwrap_test!(
2222
name: notify_one,
2323
test_body: {
@@ -38,7 +38,7 @@ nonpoison_and_poison_unwrap_test!(
3838
}
3939
);
4040

41-
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
41+
#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] // No threads.
4242
nonpoison_and_poison_unwrap_test!(
4343
name: notify_all,
4444
test_body: {
@@ -79,7 +79,7 @@ nonpoison_and_poison_unwrap_test!(
7979
}
8080
);
8181

82-
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
82+
#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] // No threads.
8383
nonpoison_and_poison_unwrap_test!(
8484
name: test_mutex_arc_condvar,
8585
test_body: {
@@ -116,7 +116,7 @@ nonpoison_and_poison_unwrap_test!(
116116
}
117117
);
118118

119-
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
119+
#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] // No threads.
120120
nonpoison_and_poison_unwrap_test!(
121121
name: wait_while,
122122
test_body: {
@@ -141,7 +141,7 @@ nonpoison_and_poison_unwrap_test!(
141141
}
142142
);
143143

144-
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
144+
#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] // No threads.
145145
nonpoison_and_poison_unwrap_test!(
146146
name: wait_timeout_wait,
147147
test_body: {
@@ -164,7 +164,7 @@ nonpoison_and_poison_unwrap_test!(
164164
}
165165
);
166166

167-
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
167+
#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] // No threads.
168168
nonpoison_and_poison_unwrap_test!(
169169
name: wait_timeout_while_wait,
170170
test_body: {
@@ -180,7 +180,7 @@ nonpoison_and_poison_unwrap_test!(
180180
}
181181
);
182182

183-
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
183+
#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] // No threads.
184184
nonpoison_and_poison_unwrap_test!(
185185
name: wait_timeout_while_instant_satisfy,
186186
test_body: {
@@ -197,7 +197,7 @@ nonpoison_and_poison_unwrap_test!(
197197
}
198198
);
199199

200-
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
200+
#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] // No threads.
201201
nonpoison_and_poison_unwrap_test!(
202202
name: wait_timeout_while_wake,
203203
test_body: {
@@ -226,7 +226,7 @@ nonpoison_and_poison_unwrap_test!(
226226
}
227227
);
228228

229-
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
229+
#[cfg(not(any(target_os = "emscripten", target_os = "wasi")))] // No threads.
230230
nonpoison_and_poison_unwrap_test!(
231231
name: wait_timeout_wake,
232232
test_body: {

library/std/tests/sync/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ fn result_unwrap<T, E: std::fmt::Debug>(x: Result<T, E>) -> T {
5858
/// a no-op (the identity function).
5959
///
6060
/// The test names will be prefiex with `poison_` or `nonpoison_`.
61+
///
62+
/// Important: most attributes (except `cfg`) will not work properly! (They are only applied to the first test.)
63+
/// See <https://github.com/rust-lang/rust/pull/146433> for more information.
6164
macro_rules! nonpoison_and_poison_unwrap_test {
6265
(
6366
name: $name:ident,

library/std/tests/sync/mutex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ nonpoison_and_poison_unwrap_test!(
266266
}
267267
);
268268

269-
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
269+
#[cfg(panic = "unwind")] // Requires unwinding support.
270270
nonpoison_and_poison_unwrap_test!(
271271
name: test_panics,
272272
test_body: {
@@ -297,7 +297,7 @@ nonpoison_and_poison_unwrap_test!(
297297
}
298298
);
299299

300-
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
300+
#[cfg(panic = "unwind")] // Requires unwinding support.
301301
nonpoison_and_poison_unwrap_test!(
302302
name: test_mutex_arc_access_in_unwind,
303303
test_body: {

library/std/tests/sync/rwlock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ nonpoison_and_poison_unwrap_test!(
124124
}
125125
);
126126

127-
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
127+
#[cfg(panic = "unwind")] // Requires unwinding support.
128128
nonpoison_and_poison_unwrap_test!(
129129
name: test_rw_arc_access_in_unwind,
130130
test_body: {

0 commit comments

Comments
 (0)