@@ -41,7 +41,7 @@ struct TestCtxt {
41
41
sess : session:: Session ,
42
42
path : RefCell < ~[ ast:: Ident ] > ,
43
43
ext_cx : @ExtCtxt ,
44
- testfns : ~[ Test ] ,
44
+ testfns : RefCell < ~[ Test ] > ,
45
45
is_extra : bool ,
46
46
config : ast:: CrateConfig ,
47
47
}
@@ -104,7 +104,10 @@ impl fold::ast_fold for TestHarnessGenerator {
104
104
ignore : is_ignored ( self . cx , i) ,
105
105
should_fail : should_fail ( i)
106
106
} ;
107
- self . cx . testfns . push ( test) ;
107
+ {
108
+ let mut testfns = self . cx . testfns . borrow_mut ( ) ;
109
+ testfns. get ( ) . push ( test) ;
110
+ }
108
111
// debug!("have {} test/bench functions",
109
112
// cx.testfns.len());
110
113
}
@@ -155,7 +158,7 @@ fn generate_test_harness(sess: session::Session, crate: ast::Crate)
155
158
sess : sess,
156
159
ext_cx : ExtCtxt :: new ( sess. parse_sess , sess. opts . cfg . clone ( ) ) ,
157
160
path : RefCell :: new ( ~[ ] ) ,
158
- testfns : ~[ ] ,
161
+ testfns : RefCell :: new ( ~[ ] ) ,
159
162
is_extra : is_extra ( & crate ) ,
160
163
config : crate . config. clone ( ) ,
161
164
} ;
@@ -389,10 +392,13 @@ fn is_extra(crate: &ast::Crate) -> bool {
389
392
}
390
393
391
394
fn mk_test_descs ( cx : & TestCtxt ) -> @ast:: Expr {
392
- debug ! ( "building test vector from {} tests" , cx. testfns. len( ) ) ;
393
395
let mut descs = ~[ ] ;
394
- for test in cx. testfns . iter ( ) {
395
- descs. push ( mk_test_desc_and_fn_rec ( cx, test) ) ;
396
+ {
397
+ let testfns = cx. testfns . borrow ( ) ;
398
+ debug ! ( "building test vector from {} tests" , testfns. get( ) . len( ) ) ;
399
+ for test in testfns. get ( ) . iter ( ) {
400
+ descs. push ( mk_test_desc_and_fn_rec ( cx, test) ) ;
401
+ }
396
402
}
397
403
398
404
let inner_expr = @ast:: Expr {
0 commit comments