diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2016-03-28 17:49:02 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2016-04-06 12:42:46 -0400 |
| commit | 068142a2e6d8a72e52091ccebd3368ffaf267643 (patch) | |
| tree | 0349999e2e90268f37a3ad230be511fe2280bbd9 /src/compiletest | |
| parent | 3fb40c1d95dd3a14ad14d71e3ec847a0a102bd49 (diff) | |
| download | rust-068142a2e6d8a72e52091ccebd3368ffaf267643.tar.gz rust-068142a2e6d8a72e52091ccebd3368ffaf267643.zip | |
add incremental test runner and some tests
Diffstat (limited to 'src/compiletest')
| -rw-r--r-- | src/compiletest/common.rs | 5 | ||||
| -rw-r--r-- | src/compiletest/compiletest.rs | 3 | ||||
| -rw-r--r-- | src/compiletest/runtest.rs | 65 |
3 files changed, 71 insertions, 2 deletions
diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index bfcc1759b95..a6960ff1785 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -25,7 +25,8 @@ pub enum Mode { DebugInfoLldb, Codegen, Rustdoc, - CodegenUnits + CodegenUnits, + Incremental, } impl FromStr for Mode { @@ -43,6 +44,7 @@ impl FromStr for Mode { "codegen" => Ok(Codegen), "rustdoc" => Ok(Rustdoc), "codegen-units" => Ok(CodegenUnits), + "incremental" => Ok(Incremental), _ => Err(()), } } @@ -62,6 +64,7 @@ impl fmt::Display for Mode { Codegen => "codegen", Rustdoc => "rustdoc", CodegenUnits => "codegen-units", + Incremental => "incremental", }, f) } } diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 787d77bc56c..1c06b2a23d5 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -71,7 +71,8 @@ pub fn parse_config(args: Vec<String> ) -> Config { reqopt("", "aux-base", "directory to find auxiliary test files", "PATH"), reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET"), reqopt("", "mode", "which sort of compile tests to run", - "(compile-fail|parse-fail|run-fail|run-pass|run-pass-valgrind|pretty|debug-info)"), + "(compile-fail|parse-fail|run-fail|run-pass|\ + run-pass-valgrind|pretty|debug-info|incremental)"), optflag("", "ignored", "run tests marked as ignored"), optopt("", "runtool", "supervisor program to run tests under \ (eg. emulator, valgrind)", "PROGRAM"), diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 24fd413ef09..802b967ed7d 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -11,6 +11,7 @@ use common::Config; use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; use common::{Codegen, DebugInfoLldb, DebugInfoGdb, Rustdoc, CodegenUnits}; +use common::{Incremental}; use errors::{self, ErrorKind}; use header::TestProps; use header; @@ -59,6 +60,7 @@ pub fn run(config: Config, testpaths: &TestPaths) { Codegen => run_codegen_test(&config, &props, &testpaths), Rustdoc => run_rustdoc_test(&config, &props, &testpaths), CodegenUnits => run_codegen_units_test(&config, &props, &testpaths), + Incremental => run_incremental_test(&config, &props, &testpaths), } } @@ -1966,3 +1968,66 @@ fn run_codegen_units_test(config: &Config, props: &TestProps, testpaths: &TestPa panic!(); } } + +fn run_incremental_test(config: &Config, props: &TestProps, testpaths: &TestPaths) { + // Basic plan for a test incremental/foo/bar.rs: + // - load list of revisions pass1, fail2, pass3 + // - each should begin with `pass` or `fail` + // - if `pass`, expect compile to succeed + // - if `fail`, expect errors from file + // - create a directory build/foo/bar.incremental + // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C pass1 + // - because name of revision starts with "pass", expect success + // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C fail2 + // - because name of revision starts with "fail", expect an error + // - load expected errors as usual, but filter for those that end in `[fail2]` + // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C pass3 + // - because name of revision starts with "pass", expect success + // - execute build/foo/bar.exe and save output + // + // FIXME -- use non-incremental mode as an oracle? That doesn't apply + // to #[rustc_dirty] and clean tests I guess + + assert!(!props.revisions.is_empty(), "incremental tests require a list of revisions"); + + let output_base_name = output_base_name(config, testpaths); + + // Create the incremental workproduct directory. + let incremental_dir = output_base_name.with_extension("incremental"); + if incremental_dir.exists() { + fs::remove_dir_all(&incremental_dir).unwrap(); + } + fs::create_dir_all(&incremental_dir).unwrap(); + + if config.verbose { + print!("incremental_dir={}", incremental_dir.display()); + } + + for revision in &props.revisions { + let mut revision_props = props.clone(); + header::load_props_into(&mut revision_props, &testpaths.file, Some(&revision)); + + revision_props.compile_flags.extend(vec![ + format!("-Z"), + format!("incremental={}", incremental_dir.display()), + format!("--cfg"), + format!("{}", revision), + ]); + + if config.verbose { + print!("revision={:?} revision_props={:#?}", revision, revision_props); + } + + if revision.starts_with("rpass") { + run_rpass_test_revision(config, &revision_props, testpaths, Some(&revision)); + } else if revision.starts_with("rfail") { + run_rfail_test_revision(config, &revision_props, testpaths, Some(&revision)); + } else if revision.starts_with("cfail") { + run_cfail_test_revision(config, &revision_props, testpaths, Some(&revision)); + } else { + fatal( + Some(revision), + "revision name must begin with rpass, rfail, or cfail"); + } + } +} |
