@@ -8,6 +8,7 @@ use std::*;
8
8
use fail:: fail_point;
9
9
10
10
#[ test]
11
+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
11
12
fn test_off ( ) {
12
13
let f = || {
13
14
fail_point ! ( "off" , |_| 2 ) ;
@@ -21,6 +22,7 @@ fn test_off() {
21
22
22
23
#[ test]
23
24
#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
25
+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
24
26
fn test_return ( ) {
25
27
let f = || {
26
28
fail_point ! ( "return" , |s: Option <String >| s
@@ -38,6 +40,7 @@ fn test_return() {
38
40
39
41
#[ test]
40
42
#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
43
+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
41
44
fn test_sleep ( ) {
42
45
let f = || {
43
46
fail_point ! ( "sleep" ) ;
@@ -55,6 +58,7 @@ fn test_sleep() {
55
58
#[ test]
56
59
#[ should_panic]
57
60
#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
61
+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
58
62
fn test_panic ( ) {
59
63
let f = || {
60
64
fail_point ! ( "panic" ) ;
@@ -65,6 +69,7 @@ fn test_panic() {
65
69
66
70
#[ test]
67
71
#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
72
+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
68
73
fn test_print ( ) {
69
74
struct LogCollector ( Arc < Mutex < Vec < String > > > ) ;
70
75
impl log:: Log for LogCollector {
@@ -99,6 +104,7 @@ fn test_print() {
99
104
100
105
#[ test]
101
106
#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
107
+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
102
108
fn test_pause ( ) {
103
109
let f = || {
104
110
fail_point ! ( "pause" ) ;
@@ -131,6 +137,7 @@ fn test_pause() {
131
137
}
132
138
133
139
#[ test]
140
+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
134
141
fn test_yield ( ) {
135
142
let f = || {
136
143
fail_point ! ( "yield" ) ;
@@ -141,6 +148,7 @@ fn test_yield() {
141
148
142
149
#[ test]
143
150
#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
151
+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
144
152
fn test_callback ( ) {
145
153
let f1 = || {
146
154
fail_point ! ( "cb" ) ;
@@ -162,6 +170,7 @@ fn test_callback() {
162
170
163
171
#[ test]
164
172
#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
173
+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
165
174
fn test_delay ( ) {
166
175
let f = || fail_point ! ( "delay" ) ;
167
176
let timer = Instant :: now ( ) ;
@@ -172,6 +181,7 @@ fn test_delay() {
172
181
173
182
#[ test]
174
183
#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
184
+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
175
185
fn test_freq_and_count ( ) {
176
186
let f = || {
177
187
fail_point ! ( "freq_and_count" , |s: Option <String >| s
@@ -193,6 +203,7 @@ fn test_freq_and_count() {
193
203
194
204
#[ test]
195
205
#[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
206
+ #[ cfg_attr( feature = "crate-isolation" , ignore) ]
196
207
fn test_condition ( ) {
197
208
let f = |_enabled| {
198
209
fail_point ! ( "condition" , _enabled, |_| 2 ) ;
@@ -214,3 +225,43 @@ fn test_list() {
214
225
fail:: cfg ( "list" , "return" ) . unwrap ( ) ;
215
226
assert ! ( fail:: list( ) . contains( & ( "list" . to_string( ) , "return" . to_string( ) ) ) ) ;
216
227
}
228
+
229
+ #[ cfg( feature = "crate-isolation" ) ]
230
+ #[ test]
231
+ #[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
232
+ fn test_crate_isolation_return_parse ( ) {
233
+ let f = || {
234
+ fail_point ! ( "isolated_return_parse" , |s: Option <String >| s
235
+ . map_or( 2 , |s| s. parse( ) . unwrap( ) ) ) ;
236
+ 0
237
+ } ;
238
+ assert_eq ! ( f( ) , 0 ) ;
239
+
240
+ fail:: cfg ( "isolated_return_parse" , "return(1000)" ) . unwrap ( ) ;
241
+ assert_eq ! ( f( ) , 0 ) ;
242
+
243
+ fail:: cfg ( "fail::isolated_return_parse" , "return(1000)" ) . unwrap ( ) ;
244
+ assert_eq ! ( f( ) , 1000 ) ;
245
+
246
+ fail:: cfg ( "fail::isolated_return_parse" , "return" ) . unwrap ( ) ;
247
+ assert_eq ! ( f( ) , 2 ) ;
248
+ }
249
+
250
+ #[ cfg( feature = "crate-isolation" ) ]
251
+ #[ test]
252
+ #[ cfg_attr( not( feature = "failpoints" ) , ignore) ]
253
+ fn test_crate_isolation_return_default ( ) {
254
+ let f = || {
255
+ fail_point ! ( "isolated_return_default" ) ;
256
+ 0
257
+ } ;
258
+ assert_eq ! ( f( ) , 0 ) ;
259
+
260
+ fail:: cfg ( "isolated_return_default" , "return(1000)" ) . unwrap ( ) ;
261
+ let result = std:: panic:: catch_unwind ( f)
262
+ . expect ( "callback should not panic as fail point should not be set" ) ;
263
+ assert_eq ! ( result, 0 ) ;
264
+
265
+ fail:: cfg ( "fail::isolated_return_default" , "return(1000)" ) . unwrap ( ) ;
266
+ std:: panic:: catch_unwind ( f) . expect_err ( "callback should panic as fail point is set" ) ;
267
+ }
0 commit comments