]> git.lizzy.rs Git - rust.git/commitdiff
compiletest: account for `ui` reference files when deciding to skip
authorNiko Matsakis <niko@alum.mit.edu>
Wed, 6 Dec 2017 11:21:23 +0000 (06:21 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 6 Dec 2017 11:31:10 +0000 (06:31 -0500)
src/tools/compiletest/src/common.rs
src/tools/compiletest/src/header.rs
src/tools/compiletest/src/main.rs
src/tools/compiletest/src/runtest.rs

index 660462ad419f70c70a047590c735a102dcc7f0ee..48c3c5c819862a406d129363d1a23303a288dd55 100644 (file)
@@ -13,7 +13,7 @@
 use std::str::FromStr;
 use std::path::PathBuf;
 
-use test::ColorConfig;
+use test::{ColorConfig, TestPaths};
 
 #[derive(Clone, Copy, PartialEq, Debug)]
 pub enum Mode {
@@ -221,3 +221,17 @@ pub struct Config {
     pub llvm_cxxflags: String,
     pub nodejs: Option<String>,
 }
+
+/// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`.
+pub fn expected_output_path(testpaths: &TestPaths, revision: Option<&str>, kind: &str) -> PathBuf {
+    assert!(UI_EXTENSIONS.contains(&kind));
+    let extension = match revision {
+        Some(r) => format!("{}.{}", r, kind),
+        None => kind.to_string(),
+    };
+    testpaths.file.with_extension(extension)
+}
+
+pub const UI_EXTENSIONS: &[&str] = &[UI_STDERR, UI_STDOUT];
+pub const UI_STDERR: &str = "stderr";
+pub const UI_STDOUT: &str = "stdout";
index c853d53829c60e2f92c04d8686a6b346fd8e4a47..e7851c3632761c67c3510071dc82fb52c5dd5d72 100644 (file)
@@ -26,6 +26,7 @@ pub struct EarlyProps {
     pub ignore: bool,
     pub should_fail: bool,
     pub aux: Vec<String>,
+    pub revisions: Vec<String>,
 }
 
 impl EarlyProps {
@@ -34,6 +35,7 @@ pub fn from_file(config: &Config, testfile: &Path) -> Self {
             ignore: false,
             should_fail: false,
             aux: Vec::new(),
+            revisions: vec![],
         };
 
         iter_header(testfile,
@@ -50,6 +52,10 @@ pub fn from_file(config: &Config, testfile: &Path) -> Self {
                 props.aux.push(s);
             }
 
+            if let Some(r) = config.parse_revisions(ln) {
+                props.revisions.extend(r);
+            }
+
             props.should_fail = props.should_fail || config.parse_name_directive(ln, "should-fail");
         });
 
index d8ccb285cc513b54d4c7af562997982a017207d1..fac3b71f82cc444c5bcdd78312549dea3b047f4e 100644 (file)
@@ -34,6 +34,7 @@
 use getopts::Options;
 use common::Config;
 use common::{DebugInfoGdb, DebugInfoLldb, Mode, Pretty};
+use common::{expected_output_path, UI_EXTENSIONS};
 use test::{ColorConfig, TestPaths};
 use util::logv;
 
@@ -673,6 +674,20 @@ fn up_to_date(config: &Config, testpaths: &TestPaths, props: &EarlyProps) -> boo
         inputs.push(mtime(&rustdoc_path));
         inputs.push(mtime(&rust_src_dir.join("src/etc/htmldocck.py")));
     }
+
+    // UI test files.
+    for extension in UI_EXTENSIONS {
+        for revision in &props.revisions {
+            let path = &expected_output_path(testpaths, Some(revision), extension);
+            inputs.push(mtime(path));
+        }
+
+        if props.revisions.is_empty() {
+            let path = &expected_output_path(testpaths, None, extension);
+            inputs.push(mtime(path));
+        }
+    }
+
     inputs.iter().any(|input| *input > stamp)
 }
 
index d89dc855cb03c7623264954fbb6f2c1b87b80bc6..4b430f0cd70d5bfa2511a80a8ae0074e5936d93f 100644 (file)
@@ -12,6 +12,7 @@
 use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
 use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc};
 use common::{Incremental, MirOpt, RunMake, Ui};
+use common::{expected_output_path, UI_STDERR, UI_STDOUT};
 use diff;
 use errors::{self, Error, ErrorKind};
 use filetime::FileTime;
@@ -2387,10 +2388,10 @@ fn run_ui_test(&self) {
 
         let proc_res = self.compile_test();
 
-        let expected_stderr_path = self.expected_output_path("stderr");
+        let expected_stderr_path = self.expected_output_path(UI_STDERR);
         let expected_stderr = self.load_expected_output(&expected_stderr_path);
 
-        let expected_stdout_path = self.expected_output_path("stdout");
+        let expected_stdout_path = self.expected_output_path(UI_STDOUT);
         let expected_stdout = self.load_expected_output(&expected_stdout_path);
 
         let normalized_stdout =
@@ -2672,11 +2673,7 @@ fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> S
     }
 
     fn expected_output_path(&self, kind: &str) -> PathBuf {
-        let extension = match self.revision {
-            Some(r) => format!("{}.{}", r, kind),
-            None => kind.to_string(),
-        };
-        self.testpaths.file.with_extension(extension)
+        expected_output_path(&self.testpaths, self.revision, kind)
     }
 
     fn load_expected_output(&self, path: &Path) -> String {