From 86812902402758bb2ffa2ff594fcfd3546bab6aa Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 6 Dec 2017 06:21:23 -0500 Subject: [PATCH] compiletest: account for `ui` reference files when deciding to skip --- src/tools/compiletest/src/common.rs | 16 +++++++++++++++- src/tools/compiletest/src/header.rs | 6 ++++++ src/tools/compiletest/src/main.rs | 15 +++++++++++++++ src/tools/compiletest/src/runtest.rs | 11 ++++------- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 660462ad419..48c3c5c8198 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -13,7 +13,7 @@ use std::fmt; 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, } + +/// 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"; diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index c853d53829c..e7851c36327 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -26,6 +26,7 @@ pub struct EarlyProps { pub ignore: bool, pub should_fail: bool, pub aux: Vec, + pub revisions: Vec, } impl EarlyProps { @@ -34,6 +35,7 @@ impl EarlyProps { ignore: false, should_fail: false, aux: Vec::new(), + revisions: vec![], }; iter_header(testfile, @@ -50,6 +52,10 @@ impl EarlyProps { 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"); }); diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index d8ccb285cc5..fac3b71f82c 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -34,6 +34,7 @@ use filetime::FileTime; 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) } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index d89dc855cb0..4b430f0cd70 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -12,6 +12,7 @@ use common::Config; 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 @@ impl<'test> TestCx<'test> { 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 @@ impl<'test> TestCx<'test> { } 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 {