compiletest: account for ui
reference files when deciding to skip
This commit is contained in:
parent
a4cafe46c2
commit
8681290240
@ -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<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";
|
||||
|
@ -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 @@ 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");
|
||||
});
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user