Skip to content

Commit 8681290

Browse files
committed
compiletest: account for ui reference files when deciding to skip
1 parent a4cafe4 commit 8681290

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

src/tools/compiletest/src/common.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::fmt;
1313
use std::str::FromStr;
1414
use std::path::PathBuf;
1515

16-
use test::ColorConfig;
16+
use test::{ColorConfig, TestPaths};
1717

1818
#[derive(Clone, Copy, PartialEq, Debug)]
1919
pub enum Mode {
@@ -221,3 +221,17 @@ pub struct Config {
221221
pub llvm_cxxflags: String,
222222
pub nodejs: Option<String>,
223223
}
224+
225+
/// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`.
226+
pub fn expected_output_path(testpaths: &TestPaths, revision: Option<&str>, kind: &str) -> PathBuf {
227+
assert!(UI_EXTENSIONS.contains(&kind));
228+
let extension = match revision {
229+
Some(r) => format!("{}.{}", r, kind),
230+
None => kind.to_string(),
231+
};
232+
testpaths.file.with_extension(extension)
233+
}
234+
235+
pub const UI_EXTENSIONS: &[&str] = &[UI_STDERR, UI_STDOUT];
236+
pub const UI_STDERR: &str = "stderr";
237+
pub const UI_STDOUT: &str = "stdout";

src/tools/compiletest/src/header.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub struct EarlyProps {
2626
pub ignore: bool,
2727
pub should_fail: bool,
2828
pub aux: Vec<String>,
29+
pub revisions: Vec<String>,
2930
}
3031

3132
impl EarlyProps {
@@ -34,6 +35,7 @@ impl EarlyProps {
3435
ignore: false,
3536
should_fail: false,
3637
aux: Vec::new(),
38+
revisions: vec![],
3739
};
3840

3941
iter_header(testfile,
@@ -50,6 +52,10 @@ impl EarlyProps {
5052
props.aux.push(s);
5153
}
5254

55+
if let Some(r) = config.parse_revisions(ln) {
56+
props.revisions.extend(r);
57+
}
58+
5359
props.should_fail = props.should_fail || config.parse_name_directive(ln, "should-fail");
5460
});
5561

src/tools/compiletest/src/main.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use filetime::FileTime;
3434
use getopts::Options;
3535
use common::Config;
3636
use common::{DebugInfoGdb, DebugInfoLldb, Mode, Pretty};
37+
use common::{expected_output_path, UI_EXTENSIONS};
3738
use test::{ColorConfig, TestPaths};
3839
use util::logv;
3940

@@ -673,6 +674,20 @@ fn up_to_date(config: &Config, testpaths: &TestPaths, props: &EarlyProps) -> boo
673674
inputs.push(mtime(&rustdoc_path));
674675
inputs.push(mtime(&rust_src_dir.join("src/etc/htmldocck.py")));
675676
}
677+
678+
// UI test files.
679+
for extension in UI_EXTENSIONS {
680+
for revision in &props.revisions {
681+
let path = &expected_output_path(testpaths, Some(revision), extension);
682+
inputs.push(mtime(path));
683+
}
684+
685+
if props.revisions.is_empty() {
686+
let path = &expected_output_path(testpaths, None, extension);
687+
inputs.push(mtime(path));
688+
}
689+
}
690+
676691
inputs.iter().any(|input| *input > stamp)
677692
}
678693

src/tools/compiletest/src/runtest.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use common::Config;
1212
use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
1313
use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc};
1414
use common::{Incremental, MirOpt, RunMake, Ui};
15+
use common::{expected_output_path, UI_STDERR, UI_STDOUT};
1516
use diff;
1617
use errors::{self, Error, ErrorKind};
1718
use filetime::FileTime;
@@ -2387,10 +2388,10 @@ impl<'test> TestCx<'test> {
23872388

23882389
let proc_res = self.compile_test();
23892390

2390-
let expected_stderr_path = self.expected_output_path("stderr");
2391+
let expected_stderr_path = self.expected_output_path(UI_STDERR);
23912392
let expected_stderr = self.load_expected_output(&expected_stderr_path);
23922393

2393-
let expected_stdout_path = self.expected_output_path("stdout");
2394+
let expected_stdout_path = self.expected_output_path(UI_STDOUT);
23942395
let expected_stdout = self.load_expected_output(&expected_stdout_path);
23952396

23962397
let normalized_stdout =
@@ -2672,11 +2673,7 @@ impl<'test> TestCx<'test> {
26722673
}
26732674

26742675
fn expected_output_path(&self, kind: &str) -> PathBuf {
2675-
let extension = match self.revision {
2676-
Some(r) => format!("{}.{}", r, kind),
2677-
None => kind.to_string(),
2678-
};
2679-
self.testpaths.file.with_extension(extension)
2676+
expected_output_path(&self.testpaths, self.revision, kind)
26802677
}
26812678

26822679
fn load_expected_output(&self, path: &Path) -> String {

0 commit comments

Comments
 (0)