]> git.lizzy.rs Git - rust.git/commitdiff
pass revision and incr_comp directory to auxbuild
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 5 May 2016 00:44:22 +0000 (20:44 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 18 May 2016 14:11:35 +0000 (10:11 -0400)
This is needed for incremental compilation harness to support
cross-crate testing. Also support cfg for typechecking prettyprint

src/tools/compiletest/src/header.rs
src/tools/compiletest/src/runtest.rs

index b5cebe2e3ea2984bb5bae25b52c80217e2966d05..7593033ffe3991f9c9791aedae294056a9f335bf 100644 (file)
@@ -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 @@ pub fn new() -> Self {
             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);
index a213c6d2d54a27cc17bb9dac6808ff39d3fafc86..f89ff6b38492048443a7443b82f170bc2935e4ab 100644 (file)
@@ -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 @@ fn make_typecheck_args(&self) -> ProcArgs {
                             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 @@ fn document(&self, out_dir: &Path) -> ProcRes {
         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 @@ fn compose_and_run_compiler(&self, args: ProcArgs, input: Option<String>) -> Pro
 
         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 @@ fn make_compile_args(&self,
                             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 @@ fn run_incremental_test(&self) {
 
         // 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,