From b808eaba37c589544cc90c473f5f9d84a507afea Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 6 Nov 2012 23:26:44 -0800 Subject: [PATCH] rustc: Generate test code when in the 'test' config --- src/librustc/front/test.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index c839be0739f9..4a6936a32a55 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -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)