Skip to content

Commit 39ee381

Browse files
committed
---
yaml --- r: 3829 b: refs/heads/master c: 94e1b36 h: refs/heads/master i: 3827: a0ee167 v: v3
1 parent 0a52872 commit 39ee381

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 2e46438507e95462f38f28c3a03acd5cd00e8890
2+
refs/heads/master: 94e1b362f06cba2f2cc894cff44d0fdde4cb204a

trunk/src/comp/front/test.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,20 @@ fn mk_test_desc_rec(&test_ctxt cx, ast::ident[] path) -> @ast::expr {
249249
}
250250

251251
fn mk_main(&test_ctxt cx) -> @ast::item {
252-
auto ret_ty = @rec(node=ast::ty_int,
253-
span=rec(lo=0u, hi=0u));
254252

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,
257266
purity = ast::impure_fn,
258267
cf = ast::return,
259268
constraints = ~[]);
@@ -281,6 +290,18 @@ fn mk_main(&test_ctxt cx) -> @ast::item {
281290

282291
fn mk_test_main_call(&test_ctxt cx) -> @ast::expr {
283292

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=0u, hi=0u));
303+
304+
// Call __test::test to generate the vector of test_descs
284305
let ast::path test_path = nospan(rec(global = false,
285306
idents = ~["tests"],
286307
types = ~[]));
@@ -297,6 +318,7 @@ fn mk_test_main_call(&test_ctxt cx) -> @ast::expr {
297318
node = test_call_expr_,
298319
span = rec(lo=0u, hi=0u));
299320

321+
// Call std::test::test_main
300322
let ast::path test_main_path = nospan(rec(global = false,
301323
idents = ~["std",
302324
"test",
@@ -311,7 +333,8 @@ fn mk_test_main_call(&test_ctxt cx) -> @ast::expr {
311333
span = rec(lo=0u, hi=0u));
312334

313335
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]);
315338

316339
let ast::expr test_main_call_expr = rec(id = cx.next_node_id(),
317340
node = test_main_call_expr_,

trunk/src/lib/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type test_desc = rec(test_name name,
2727

2828
// The default console test runner. It accepts the command line
2929
// arguments and a vector of test_descs (generated at compile time).
30-
fn test_main(&test_desc[] tests) -> int {
30+
fn test_main(&vec[str] args, &test_desc[] tests) -> int {
3131
if (run_tests(tests)) {
3232
ret 0;
3333
} else {

0 commit comments

Comments
 (0)