diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2016-05-04 20:44:22 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2016-05-18 10:11:35 -0400 |
| commit | 08837d2975d5c642a4e625501ef452f43e217dc6 (patch) | |
| tree | 499e6a2177228a01eefb17cf0d9c0f45b566f255 | |
| parent | 8f3a8c24cd667da6c1e8ba751ba9896c7f9ad293 (diff) | |
| download | rust-08837d2975d5c642a4e625501ef452f43e217dc6.tar.gz rust-08837d2975d5c642a4e625501ef452f43e217dc6.zip | |
pass revision and incr_comp directory to auxbuild
This is needed for incremental compilation harness to support cross-crate testing. Also support cfg for typechecking prettyprint
| -rw-r--r-- | src/tools/compiletest/src/header.rs | 16 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 34 |
2 files changed, 40 insertions, 10 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index b5cebe2e3ea..7593033ffe3 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -162,6 +162,11 @@ pub struct TestProps { pub forbid_output: Vec<String>, // Revisions to test for incremental compilation. pub revisions: Vec<String>, + // Directory (if any) to use for incremental compilation. This is + // not set by end-users; rather it is set by the incremental + // testing harness and used when generating compilation + // arguments. (In particular, it propagates to the aux-builds.) + pub incremental_dir: Option<PathBuf>, } impl TestProps { @@ -197,9 +202,20 @@ impl TestProps { pretty_mode: format!("normal"), pretty_compare_only: pretty_compare_only, forbid_output: forbid_output, + incremental_dir: None, } } + pub fn from_aux_file(&self, testfile: &Path, cfg: Option<&str>) -> Self { + let mut props = TestProps::new(); + + // copy over select properties to the aux build: + props.incremental_dir = self.incremental_dir.clone(); + props.load_from(testfile, cfg); + + props + } + pub fn from_file(testfile: &Path) -> Self { let mut props = TestProps::new(); props.load_from(testfile, None); diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index a213c6d2d54..f89ff6b3849 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -63,10 +63,6 @@ pub fn run(config: Config, testpaths: &TestPaths) { for revision in &base_props.revisions { let mut revision_props = base_props.clone(); revision_props.load_from(&testpaths.file, Some(&revision)); - revision_props.compile_flags.extend(vec![ - format!("--cfg"), - format!("{}", revision), - ]); let rev_cx = TestCx { config: &config, props: &revision_props, @@ -383,6 +379,12 @@ actual:\n\ self.config.build_base.to_str().unwrap().to_owned(), "-L".to_owned(), aux_dir.to_str().unwrap().to_owned()); + if let Some(revision) = self.revision { + args.extend(vec![ + format!("--cfg"), + format!("{}", revision), + ]); + } args.extend(self.split_maybe_args(&self.config.target_rustcflags)); args.extend(self.props.compile_flags.iter().cloned()); // FIXME (#9639): This needs to handle non-utf8 paths @@ -1102,7 +1104,7 @@ actual:\n\ if self.props.build_aux_docs { for rel_ab in &self.props.aux_builds { let aux_testpaths = self.compute_aux_test_paths(rel_ab); - let aux_props = TestProps::from_file(&aux_testpaths.file); + let aux_props = self.props.from_aux_file(&aux_testpaths.file, self.revision); let aux_cx = TestCx { config: self.config, props: &aux_props, @@ -1186,7 +1188,7 @@ actual:\n\ for rel_ab in &self.props.aux_builds { let aux_testpaths = self.compute_aux_test_paths(rel_ab); - let aux_props = TestProps::from_file(&aux_testpaths.file); + let aux_props = self.props.from_aux_file(&aux_testpaths.file, self.revision); let mut crate_type = if aux_props.no_prefer_dynamic { Vec::new() } else { @@ -1291,6 +1293,21 @@ actual:\n\ self.config.build_base.to_str().unwrap().to_owned(), format!("--target={}", target)); + if let Some(revision) = self.revision { + args.extend(vec![ + format!("--cfg"), + format!("{}", revision), + ]); + } + + if let Some(ref incremental_dir) = self.props.incremental_dir { + args.extend(vec![ + format!("-Z"), + format!("incremental={}", incremental_dir.display()), + ]); + } + + match self.config.mode { CompileFail | ParseFail | @@ -1980,10 +1997,7 @@ actual:\n\ // Add an extra flag pointing at the incremental directory. let mut revision_props = self.props.clone(); - revision_props.compile_flags.extend(vec![ - format!("-Z"), - format!("incremental={}", incremental_dir.display()), - ]); + revision_props.incremental_dir = Some(incremental_dir); let revision_cx = TestCx { config: self.config, |
