From ea5c413427553507698a3358488199fcb00ca1ce Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 9 May 2013 15:15:54 +1000 Subject: [PATCH 1/2] Perform expansion before stripping/building a test harness. This allows macros to create tests and benchmarks. --- src/librustc/driver/driver.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 5bda6daa69b9..01a68255c3ea 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -183,16 +183,16 @@ pub fn compile_rest(sess: Session, *sess.building_library = session::building_library( sess.opts.crate_type, crate, sess.opts.test); + crate = time(time_passes, ~"expansion", || + syntax::ext::expand::expand_crate(sess.parse_sess, copy cfg, + crate)); + crate = time(time_passes, ~"configuration", || front::config::strip_unconfigured_items(crate)); crate = time(time_passes, ~"maybe building test harness", || front::test::modify_for_testing(sess, crate)); - crate = time(time_passes, ~"expansion", || - syntax::ext::expand::expand_crate(sess.parse_sess, copy cfg, - crate)); - if upto == cu_expand { return (crate, None); } crate = time(time_passes, ~"intrinsic injection", || From 9b30fa31168c9337da36a95484b2550954528216 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 11 May 2013 18:18:02 +1000 Subject: [PATCH 2/2] Correct testcases that passed because fns with #[test] were stripped before expansion. --- src/test/run-pass/issue-2904.rs | 6 ------ src/test/run-pass/issue-3424.rs | 3 +-- src/test/run-pass/issue-3559.rs | 6 ++---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 77cc6b3e1b5b..304d8fe28846 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -79,12 +79,6 @@ mod test { pub fn trivial_to_str() { assert!(lambda.to_str() == "\\") } - - #[test] - pub fn read_simple_board() { - let s = include_str!("./maps/contest1.map"); - io::with_str_reader(s, read_board_grid) - } } pub fn main() {} diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs index d79eef46f052..70a01f8cf02d 100644 --- a/src/test/run-pass/issue-3424.rs +++ b/src/test/run-pass/issue-3424.rs @@ -16,12 +16,11 @@ use core::path::{Path}; type rsrc_loader = ~fn(path: &Path) -> result::Result<~str, ~str>; -#[test] fn tester() { let loader: rsrc_loader = |_path| {result::Ok(~"more blah")}; - let path = path::from_str("blah"); + let path = path::Path("blah"); assert!(loader(&path).is_ok()); } diff --git a/src/test/run-pass/issue-3559.rs b/src/test/run-pass/issue-3559.rs index 334831fea4d0..b3f3aed9ea1f 100644 --- a/src/test/run-pass/issue-3559.rs +++ b/src/test/run-pass/issue-3559.rs @@ -1,4 +1,4 @@ -// xfail-fast +// xfail-test #4276 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at @@ -15,7 +15,6 @@ extern mod std; use core::io::{WriterUtil}; -#[cfg(test)] fn check_strs(actual: &str, expected: &str) -> bool { if actual != expected @@ -26,10 +25,9 @@ fn check_strs(actual: &str, expected: &str) -> bool return true; } -#[test] fn tester() { - let mut table = core::hashmap::HashMap(); + let mut table = core::hashmap::HashMap::new(); table.insert(@~"one", 1); table.insert(@~"two", 2); assert!(check_strs(table.to_str(), ~"xxx")); // not sure what expected should be