syntax: clarify field name
The value of this field is meant to indicate whether or not the crate is rustc's libtest itself - not whether or not it is a test crate generally.
This commit is contained in:
parent
f2fb45723a
commit
0463566f27
1 changed files with 5 additions and 10 deletions
|
@ -61,7 +61,7 @@ struct TestCtxt<'a> {
|
||||||
ext_cx: ExtCtxt<'a>,
|
ext_cx: ExtCtxt<'a>,
|
||||||
testfns: Vec<Test>,
|
testfns: Vec<Test>,
|
||||||
reexport_test_harness_main: Option<Symbol>,
|
reexport_test_harness_main: Option<Symbol>,
|
||||||
is_test_crate: bool,
|
is_libtest: bool,
|
||||||
ctxt: SyntaxContext,
|
ctxt: SyntaxContext,
|
||||||
|
|
||||||
// top-level re-export submodule, filled out after folding is finished
|
// top-level re-export submodule, filled out after folding is finished
|
||||||
|
@ -271,13 +271,15 @@ fn generate_test_harness(sess: &ParseSess,
|
||||||
let krate = cleaner.fold_crate(krate);
|
let krate = cleaner.fold_crate(krate);
|
||||||
|
|
||||||
let mark = Mark::fresh(Mark::root());
|
let mark = Mark::fresh(Mark::root());
|
||||||
|
|
||||||
let mut cx: TestCtxt = TestCtxt {
|
let mut cx: TestCtxt = TestCtxt {
|
||||||
span_diagnostic: sd,
|
span_diagnostic: sd,
|
||||||
ext_cx: ExtCtxt::new(sess, ExpansionConfig::default("test".to_string()), resolver),
|
ext_cx: ExtCtxt::new(sess, ExpansionConfig::default("test".to_string()), resolver),
|
||||||
path: Vec::new(),
|
path: Vec::new(),
|
||||||
testfns: Vec::new(),
|
testfns: Vec::new(),
|
||||||
reexport_test_harness_main,
|
reexport_test_harness_main,
|
||||||
is_test_crate: is_test_crate(&krate),
|
// NB: doesn't consider the value of `--crate-name` passed on the command line.
|
||||||
|
is_libtest: attr::find_crate_name(&krate.attrs).map(|s| s == "test").unwrap_or(false),
|
||||||
toplevel_reexport: None,
|
toplevel_reexport: None,
|
||||||
ctxt: SyntaxContext::empty().apply_mark(mark),
|
ctxt: SyntaxContext::empty().apply_mark(mark),
|
||||||
};
|
};
|
||||||
|
@ -452,7 +454,7 @@ mod __test {
|
||||||
fn mk_std(cx: &TestCtxt) -> P<ast::Item> {
|
fn mk_std(cx: &TestCtxt) -> P<ast::Item> {
|
||||||
let id_test = Ident::from_str("test");
|
let id_test = Ident::from_str("test");
|
||||||
let sp = ignored_span(cx, DUMMY_SP);
|
let sp = ignored_span(cx, DUMMY_SP);
|
||||||
let (vi, vis, ident) = if cx.is_test_crate {
|
let (vi, vis, ident) = if cx.is_libtest {
|
||||||
(ast::ItemKind::Use(
|
(ast::ItemKind::Use(
|
||||||
P(nospan(ast::ViewPathSimple(id_test,
|
P(nospan(ast::ViewPathSimple(id_test,
|
||||||
path_node(vec![id_test]))))),
|
path_node(vec![id_test]))))),
|
||||||
|
@ -606,13 +608,6 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
|
||||||
test_descs)
|
test_descs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_test_crate(krate: &ast::Crate) -> bool {
|
|
||||||
match attr::find_crate_name(&krate.attrs) {
|
|
||||||
Some(s) if "test" == s.as_str() => true,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mk_test_descs(cx: &TestCtxt) -> P<ast::Expr> {
|
fn mk_test_descs(cx: &TestCtxt) -> P<ast::Expr> {
|
||||||
debug!("building test vector from {} tests", cx.testfns.len());
|
debug!("building test vector from {} tests", cx.testfns.len());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue