rustc: Generate test code when in the 'test' config

This commit is contained in:
Brian Anderson 2012-11-06 23:26:44 -08:00
parent 28c7a25151
commit b808eaba37

View file

@ -29,7 +29,13 @@ type test_ctxt =
fn modify_for_testing(sess: session::Session,
crate: @ast::crate) -> @ast::crate {
if sess.opts.test {
// We generate the test harness when building in the 'test'
// configuration, either with the '--test' or '--cfg test'
// command line options.
let should_test = attr::contains(crate.node.config,
attr::mk_word_item(~"test"));
if should_test {
generate_test_harness(sess, crate)
} else {
strip_test_functions(crate)