diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-07-06 14:29:50 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-07-06 14:39:36 -0700 |
| commit | b06ccb45abb5c9ea0b55c8ff8a32831188c2403f (patch) | |
| tree | becc2cf1cb9bbb9c109a86e69993a1dabfc5aa9b /src/comp/driver | |
| parent | 0eac640fdd56caa93d5f398a75d24e62feef4730 (diff) | |
| download | rust-b06ccb45abb5c9ea0b55c8ff8a32831188c2403f.tar.gz rust-b06ccb45abb5c9ea0b55c8ff8a32831188c2403f.zip | |
Begin adding unit testing infrastructure to the compiler
Add a --test flag and a pass for transforming the AST to generate a test harness. Issue #428
Diffstat (limited to 'src/comp/driver')
| -rw-r--r-- | src/comp/driver/rustc.rs | 13 | ||||
| -rw-r--r-- | src/comp/driver/session.rs | 3 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 80b94be4c53..f1bd93a4a5d 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -106,6 +106,10 @@ fn compile_input(session::session sess, ast::crate_cfg cfg, str input, if (sess.get_opts().output_type == link::output_type_none) { ret; } crate = time(time_passes, "configuration", bind front::config::strip_unconfigured_items(crate)); + if (sess.get_opts().test) { + crate = time(time_passes, "building test harness", + bind front::test::modify_for_testing(sess, crate)); + } auto ast_map = time(time_passes, "ast indexing", bind middle::ast_map::map_crate(*crate)); auto d = @@ -229,7 +233,8 @@ options: --time-passes time the individual phases of the compiler --time-llvm-passes time the individual phases of the LLVM backend --sysroot <path> override the system root (default: rustc's directory) - --no-typestate don't run the typestate pass (unsafe!)\n\n"); + --no-typestate don't run the typestate pass (unsafe!) + --test build test harness\n\n"); } fn get_os(str triple) -> session::os { @@ -324,6 +329,7 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) -> case (some(?s)) { s } }; auto cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg")); + auto test = opt_present(match, "test"); let @session::options sopts = @rec(shared=shared, optimize=opt_level, @@ -337,7 +343,8 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) -> output_type=output_type, library_search_paths=library_search_paths, sysroot=sysroot, - cfg=cfg); + cfg=cfg, + test=test); ret sopts; } @@ -367,7 +374,7 @@ fn main(vec[str] args) { optflag("c"), optopt("o"), optflag("g"), optflag("save-temps"), optopt("sysroot"), optflag("stats"), optflag("time-passes"), optflag("time-llvm-passes"), optflag("no-typestate"), - optflag("noverify"), optmulti("cfg")]; + optflag("noverify"), optmulti("cfg"), optflag("test")]; auto binary = vec::shift[str](args); auto binary_dir = fs::dirname(binary); auto match = diff --git a/src/comp/driver/session.rs b/src/comp/driver/session.rs index 3dc947477b8..7dce5b9b068 100644 --- a/src/comp/driver/session.rs +++ b/src/comp/driver/session.rs @@ -37,7 +37,8 @@ type options = str sysroot, // The crate config requested for the session, which may be combined // with additional crate configurations during the compile process - ast::crate_cfg cfg); + ast::crate_cfg cfg, + bool test); type crate_metadata = rec(str name, vec[u8] data); |
