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:
Tamir Duberstein 2017-08-20 08:40:07 -07:00
parent f2fb45723a
commit 0463566f27
No known key found for this signature in database
GPG Key ID: 1C1E98CC8E17BB89

View File

@ -61,7 +61,7 @@ struct TestCtxt<'a> {
ext_cx: ExtCtxt<'a>,
testfns: Vec<Test>,
reexport_test_harness_main: Option<Symbol>,
is_test_crate: bool,
is_libtest: bool,
ctxt: SyntaxContext,
// 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 mark = Mark::fresh(Mark::root());
let mut cx: TestCtxt = TestCtxt {
span_diagnostic: sd,
ext_cx: ExtCtxt::new(sess, ExpansionConfig::default("test".to_string()), resolver),
path: Vec::new(),
testfns: Vec::new(),
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,
ctxt: SyntaxContext::empty().apply_mark(mark),
};
@ -452,7 +454,7 @@ fn main() {
fn mk_std(cx: &TestCtxt) -> P<ast::Item> {
let id_test = Ident::from_str("test");
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(
P(nospan(ast::ViewPathSimple(id_test,
path_node(vec![id_test]))))),
@ -606,13 +608,6 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
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> {
debug!("building test vector from {} tests", cx.testfns.len());