|
11 | 11 | use common::Config; |
12 | 12 | use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; |
13 | 13 | use common::{Codegen, DebugInfoLldb, DebugInfoGdb, Rustdoc, CodegenUnits}; |
| 14 | +use common::{Incremental}; |
14 | 15 | use errors::{self, ErrorKind}; |
15 | 16 | use header::TestProps; |
16 | 17 | use header; |
@@ -59,6 +60,7 @@ pub fn run(config: Config, testpaths: &TestPaths) { |
59 | 60 | Codegen => run_codegen_test(&config, &props, &testpaths), |
60 | 61 | Rustdoc => run_rustdoc_test(&config, &props, &testpaths), |
61 | 62 | CodegenUnits => run_codegen_units_test(&config, &props, &testpaths), |
| 63 | + Incremental => run_incremental_test(&config, &props, &testpaths), |
62 | 64 | } |
63 | 65 | } |
64 | 66 |
|
@@ -1966,3 +1968,66 @@ fn run_codegen_units_test(config: &Config, props: &TestProps, testpaths: &TestPa |
1966 | 1968 | panic!(); |
1967 | 1969 | } |
1968 | 1970 | } |
| 1971 | + |
| 1972 | +fn run_incremental_test(config: &Config, props: &TestProps, testpaths: &TestPaths) { |
| 1973 | + // Basic plan for a test incremental/foo/bar.rs: |
| 1974 | + // - load list of revisions pass1, fail2, pass3 |
| 1975 | + // - each should begin with `pass` or `fail` |
| 1976 | + // - if `pass`, expect compile to succeed |
| 1977 | + // - if `fail`, expect errors from file |
| 1978 | + // - create a directory build/foo/bar.incremental |
| 1979 | + // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C pass1 |
| 1980 | + // - because name of revision starts with "pass", expect success |
| 1981 | + // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C fail2 |
| 1982 | + // - because name of revision starts with "fail", expect an error |
| 1983 | + // - load expected errors as usual, but filter for those that end in `[fail2]` |
| 1984 | + // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C pass3 |
| 1985 | + // - because name of revision starts with "pass", expect success |
| 1986 | + // - execute build/foo/bar.exe and save output |
| 1987 | + // |
| 1988 | + // FIXME -- use non-incremental mode as an oracle? That doesn't apply |
| 1989 | + // to #[rustc_dirty] and clean tests I guess |
| 1990 | + |
| 1991 | + assert!(!props.revisions.is_empty(), "incremental tests require a list of revisions"); |
| 1992 | + |
| 1993 | + let output_base_name = output_base_name(config, testpaths); |
| 1994 | + |
| 1995 | + // Create the incremental workproduct directory. |
| 1996 | + let incremental_dir = output_base_name.with_extension("incremental"); |
| 1997 | + if incremental_dir.exists() { |
| 1998 | + fs::remove_dir_all(&incremental_dir).unwrap(); |
| 1999 | + } |
| 2000 | + fs::create_dir_all(&incremental_dir).unwrap(); |
| 2001 | + |
| 2002 | + if config.verbose { |
| 2003 | + print!("incremental_dir={}", incremental_dir.display()); |
| 2004 | + } |
| 2005 | + |
| 2006 | + for revision in &props.revisions { |
| 2007 | + let mut revision_props = props.clone(); |
| 2008 | + header::load_props_into(&mut revision_props, &testpaths.file, Some(&revision)); |
| 2009 | + |
| 2010 | + revision_props.compile_flags.extend(vec![ |
| 2011 | + format!("-Z"), |
| 2012 | + format!("incremental={}", incremental_dir.display()), |
| 2013 | + format!("--cfg"), |
| 2014 | + format!("{}", revision), |
| 2015 | + ]); |
| 2016 | + |
| 2017 | + if config.verbose { |
| 2018 | + print!("revision={:?} revision_props={:#?}", revision, revision_props); |
| 2019 | + } |
| 2020 | + |
| 2021 | + if revision.starts_with("rpass") { |
| 2022 | + run_rpass_test_revision(config, &revision_props, testpaths, Some(&revision)); |
| 2023 | + } else if revision.starts_with("rfail") { |
| 2024 | + run_rfail_test_revision(config, &revision_props, testpaths, Some(&revision)); |
| 2025 | + } else if revision.starts_with("cfail") { |
| 2026 | + run_cfail_test_revision(config, &revision_props, testpaths, Some(&revision)); |
| 2027 | + } else { |
| 2028 | + fatal( |
| 2029 | + Some(revision), |
| 2030 | + "revision name must begin with rpass, rfail, or cfail"); |
| 2031 | + } |
| 2032 | + } |
| 2033 | +} |
0 commit comments