File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 7d475530a0aecbe243813b7cc23136058d114f2d
2
+ refs/heads/master: 4a347760edb8d8c36b9468a5db7185ac0c922ab7
Original file line number Diff line number Diff line change @@ -212,13 +212,32 @@ fn filter_tests(&test_opts opts, &test_desc[] tests) -> test_desc[] {
212
212
213
213
fn run_test( & test_desc test) -> test_result {
214
214
if ( !test. ignore) {
215
- test. fn ( ) ;
216
- ret tr_ok;
215
+ if ( run_test_fn_in_task( test. fn ) ) {
216
+ ret tr_ok;
217
+ } else {
218
+ ret tr_failed;
219
+ }
217
220
} else {
218
221
ret tr_ignored;
219
222
}
220
223
}
221
224
225
+ // We need to run our tests in another task in order to trap test failures.
226
+ // But, at least currently, functions can't be used as spawn arguments so
227
+ // we've got to treat our test functions as unsafe pointers.
228
+ fn run_test_fn_in_task( & fn( ) f) -> bool {
229
+ fn run_task( * mutable fn( ) fptr) {
230
+ task:: unsupervise( ) ;
231
+ ( * fptr) ( )
232
+ }
233
+ auto fptr = ptr:: addr_of( f) ;
234
+ auto test_task = spawn run_task( fptr) ;
235
+ ret alt ( task:: join( test_task) ) {
236
+ task:: tr_success { true }
237
+ task:: tr_failure { false }
238
+ }
239
+ }
240
+
222
241
223
242
// Local Variables:
224
243
// mode: rust;
You can’t perform that action at this time.
0 commit comments