@@ -249,11 +249,20 @@ fn mk_test_desc_rec(&test_ctxt cx, ast::ident[] path) -> @ast::expr {
249
249
}
250
250
251
251
fn mk_main( & test_ctxt cx) -> @ast:: item {
252
- auto ret_ty = @rec( node=ast:: ty_int,
253
- span=rec( lo=0 u, hi=0 u) ) ;
254
252
255
- let ast:: fn_decl decl = rec( inputs = ~[ ] ,
256
- output = ret_ty,
253
+ let ast:: mt args_mt = rec( ty = @nospan( ast:: ty_str) ,
254
+ mut = ast:: imm) ;
255
+ let ast:: ty args_ty = nospan( ast:: ty_vec( args_mt) ) ;
256
+
257
+ let ast:: arg args_arg = rec( mode = ast:: val,
258
+ ty = @args_ty,
259
+ ident = "args" ,
260
+ id = cx. next_node_id( ) ) ;
261
+
262
+ auto ret_ty = nospan( ast:: ty_int) ;
263
+
264
+ let ast:: fn_decl decl = rec( inputs = ~[ args_arg] ,
265
+ output = @ret_ty,
257
266
purity = ast:: impure_fn,
258
267
cf = ast:: return,
259
268
constraints = ~[ ] ) ;
@@ -281,6 +290,18 @@ fn mk_main(&test_ctxt cx) -> @ast::item {
281
290
282
291
fn mk_test_main_call( & test_ctxt cx) -> @ast:: expr {
283
292
293
+ // Get the args passed to main so we can pass the to test_main
294
+ let ast:: path args_path = nospan( rec( global = false,
295
+ idents = ~[ "args" ] ,
296
+ types = ~[ ] ) ) ;
297
+
298
+ let ast:: expr_ args_path_expr_ = ast:: expr_path( args_path) ;
299
+
300
+ let ast:: expr args_path_expr = rec( id = cx. next_node_id( ) ,
301
+ node = args_path_expr_,
302
+ span = rec( lo=0 u, hi=0 u) ) ;
303
+
304
+ // Call __test::test to generate the vector of test_descs
284
305
let ast:: path test_path = nospan( rec( global = false,
285
306
idents = ~[ "tests" ] ,
286
307
types = ~[ ] ) ) ;
@@ -297,6 +318,7 @@ fn mk_test_main_call(&test_ctxt cx) -> @ast::expr {
297
318
node = test_call_expr_,
298
319
span = rec( lo=0 u, hi=0 u) ) ;
299
320
321
+ // Call std::test::test_main
300
322
let ast:: path test_main_path = nospan( rec( global = false,
301
323
idents = ~[ "std" ,
302
324
"test" ,
@@ -311,7 +333,8 @@ fn mk_test_main_call(&test_ctxt cx) -> @ast::expr {
311
333
span = rec( lo=0 u, hi=0 u) ) ;
312
334
313
335
let ast:: expr_ test_main_call_expr_
314
- = ast:: expr_call( @test_main_path_expr, ~[ @test_call_expr] ) ;
336
+ = ast:: expr_call( @test_main_path_expr, ~[ @args_path_expr,
337
+ @test_call_expr] ) ;
315
338
316
339
let ast:: expr test_main_call_expr = rec( id = cx. next_node_id( ) ,
317
340
node = test_main_call_expr_,
0 commit comments