Skip to content

Commit

Permalink
Issue 4391: rustc should not silently skip tests with erroneous signa…
Browse files Browse the repository at this point in the history
…ture.
  • Loading branch information
pnkfelix committed May 2, 2013
1 parent b42ea7f commit 5f1a90e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn fold_item(cx: @mut TestCtxt, i: @ast::item, fld: @fold::ast_fold)
debug!("current path: %s",
ast_util::path_name_i(copy cx.path, cx.sess.parse_sess.interner));

if is_test_fn(i) || is_bench_fn(i) {
if is_test_fn(cx, i) || is_bench_fn(i) {
match i.node {
ast::item_fn(_, purity, _, _, _) if purity == ast::unsafe_fn => {
let sess = cx.sess;
Expand Down Expand Up @@ -169,7 +169,7 @@ fn fold_item(cx: @mut TestCtxt, i: @ast::item, fld: @fold::ast_fold)
return res;
}

fn is_test_fn(i: @ast::item) -> bool {
fn is_test_fn(cx: @mut TestCtxt, i: @ast::item) -> bool {
let has_test_attr = !attr::find_attrs_by_name(i.attrs,
~"test").is_empty();

Expand All @@ -188,6 +188,13 @@ fn is_test_fn(i: @ast::item) -> bool {
}
}

if has_test_attr && !has_test_signature(i) {
let sess = cx.sess;
sess.span_fatal(
i.span,
~"functions used as tests must have signature fn() -> ()."
);
}
return has_test_attr && has_test_signature(i);
}

Expand Down

0 comments on commit 5f1a90e

Please sign in to comment.