@@ -6,50 +6,7 @@ use std::sync::mpsc::channel;
6
6
use std:: sync:: { Arc , Condvar , MappedMutexGuard , Mutex , MutexGuard , TryLockError } ;
7
7
use std:: { hint, mem, thread} ;
8
8
9
- // Generates two test cases for both the poison and nonpoison locks.
10
- //
11
- // To write a test that uses both `poison::Mutex` and `nonpoison::Mutex`, simply call the macro
12
- // `maybe_unwrap!(...)` on the result of `mutex.lock()`. For the `poison::Mutex`, it will unwrap the
13
- // `Result` (usually `LockResult`, but it could be other kinds of results), but for the
14
- // `nonpoison::Mutex` it will do nothing.
15
- //
16
- // The `poison` test will have the same name, but with a suffix of `_unwrap_poisoned`.
17
- //
18
- // See some of the tests below for examples.
19
- macro_rules! nonpoison_and_poison_unwrap_test {
20
- (
21
- name: $name: ident,
22
- test_body: { $( $test_body: tt) * }
23
- ) => {
24
- // Creates the nonpoison test.
25
- #[ test]
26
- fn $name( ) {
27
- #[ allow( unused_imports) ]
28
- use :: std:: sync:: nonpoison:: { Mutex , MappedMutexGuard , MutexGuard } ;
29
-
30
- #[ allow( unused_macros) ]
31
- macro_rules! maybe_unwrap {
32
- ( $e: expr) => { $e } ;
33
- }
34
-
35
- $( $test_body) *
36
- }
37
-
38
- // Creates the poison test with the suffix `_unwrap_poisoned`.
39
- #[ test]
40
- fn ${ concat( $name, _unwrap_poisoned) } ( ) {
41
- #[ allow( unused_imports) ]
42
- use :: std:: sync:: { Mutex , MappedMutexGuard , MutexGuard } ;
43
-
44
- #[ allow( unused_macros) ]
45
- macro_rules! maybe_unwrap {
46
- ( $e: expr) => { Result :: unwrap( $e) } ;
47
- }
48
-
49
- $( $test_body) *
50
- }
51
- }
52
- }
9
+ use super :: nonpoison_and_poison_unwrap_test;
53
10
54
11
nonpoison_and_poison_unwrap_test ! (
55
12
name: smoke,
@@ -211,6 +168,8 @@ nonpoison_and_poison_unwrap_test!(
211
168
}
212
169
) ;
213
170
171
+ // FIXME(nonpoison_condvar): Move this to the `condvar.rs` test file once `nonpoison::condvar` gets
172
+ // implemented.
214
173
#[ test]
215
174
fn test_mutex_arc_condvar ( ) {
216
175
struct Packet < T > ( Arc < ( Mutex < T > , Condvar ) > ) ;
@@ -290,6 +249,7 @@ nonpoison_and_poison_unwrap_test!(
290
249
}
291
250
) ;
292
251
252
+ /// Creates a mutex that is immediately poisoned.
293
253
fn new_poisoned_mutex < T > ( value : T ) -> Mutex < T > {
294
254
let mutex = Mutex :: new ( value) ;
295
255
0 commit comments