make it possible to test more of ui_test
This commit is contained in:
parent
4d80880854
commit
962957f11f
@ -235,11 +235,34 @@ fn run_test(
|
||||
}
|
||||
let output = miri.output().expect("could not execute miri");
|
||||
let mut errors = config.mode.ok(output.status);
|
||||
check_test_result(
|
||||
path,
|
||||
config,
|
||||
target,
|
||||
revision,
|
||||
comments,
|
||||
&mut errors,
|
||||
&output.stdout,
|
||||
&output.stderr,
|
||||
);
|
||||
(miri, errors)
|
||||
}
|
||||
|
||||
fn check_test_result(
|
||||
path: &Path,
|
||||
config: &Config,
|
||||
target: &str,
|
||||
revision: &str,
|
||||
comments: &Comments,
|
||||
errors: &mut Errors,
|
||||
stdout: &[u8],
|
||||
stderr: &[u8],
|
||||
) {
|
||||
// Always remove annotation comments from stderr.
|
||||
let annotations = Regex::new(r"\s*//~.*").unwrap();
|
||||
let stderr = std::str::from_utf8(&output.stderr).unwrap();
|
||||
let stderr = std::str::from_utf8(stderr).unwrap();
|
||||
let stderr = annotations.replace_all(stderr, "");
|
||||
let stdout = std::str::from_utf8(&output.stdout).unwrap();
|
||||
let stdout = std::str::from_utf8(stdout).unwrap();
|
||||
// Check output files (if any)
|
||||
let revised = |extension: &str| {
|
||||
if revision.is_empty() {
|
||||
@ -252,7 +275,7 @@ fn run_test(
|
||||
check_output(
|
||||
&stderr,
|
||||
path,
|
||||
&mut errors,
|
||||
errors,
|
||||
revised("stderr"),
|
||||
target,
|
||||
&config.stderr_filters,
|
||||
@ -262,7 +285,7 @@ fn run_test(
|
||||
check_output(
|
||||
&stdout,
|
||||
path,
|
||||
&mut errors,
|
||||
errors,
|
||||
revised("stdout"),
|
||||
target,
|
||||
&config.stdout_filters,
|
||||
@ -270,8 +293,7 @@ fn run_test(
|
||||
comments,
|
||||
);
|
||||
// Check error annotations in the source against output
|
||||
check_annotations(&stderr, &mut errors, config, revision, comments);
|
||||
(miri, errors)
|
||||
check_annotations(&stderr, errors, config, revision, comments);
|
||||
}
|
||||
|
||||
fn check_annotations(
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use super::{check_annotations, Comments, Config, Error, Mode, OutputConflictHandling};
|
||||
use super::*;
|
||||
|
||||
fn config() -> Config {
|
||||
Config {
|
||||
@ -8,7 +8,7 @@ fn config() -> Config {
|
||||
target: None,
|
||||
stderr_filters: vec![],
|
||||
stdout_filters: vec![],
|
||||
root_dir: PathBuf::from("."),
|
||||
root_dir: PathBuf::from("$RUSTROOT"),
|
||||
mode: Mode::Fail,
|
||||
path_filter: vec![],
|
||||
program: PathBuf::from("cake"),
|
||||
@ -25,10 +25,12 @@ fn main() {
|
||||
let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ ERROR encountered a dangling reference (address $HEX is unallocated)
|
||||
}
|
||||
";
|
||||
let comments = Comments::parse(Path::new("<dummy>"), s);
|
||||
let path = Path::new("$DIR/<dummy>");
|
||||
let comments = Comments::parse(&path, s);
|
||||
let mut errors = vec![];
|
||||
let config = config();
|
||||
let unnormalized_stderr = r"
|
||||
// Crucially, the intended error string *does* appear in this output, as a quote of the comment itself.
|
||||
let stderr = br"
|
||||
error: Undefined Behavior: type validation failed: encountered a dangling reference (address 0x10 is unallocated)
|
||||
--> tests/compile-fail/validity/dangling_ref1.rs:6:29
|
||||
|
|
||||
@ -42,9 +44,10 @@ fn main() {
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
error: aborting due to previous error
|
||||
";
|
||||
check_annotations(unnormalized_stderr, &mut errors, &config, "", &comments);
|
||||
check_test_result(&path, &config, "", "", &comments, &mut errors, /*stdout*/ br"", stderr);
|
||||
// The "OutputDiffers" is because we cannot open the .rs file
|
||||
match &errors[..] {
|
||||
[Error::PatternNotFound { .. }] => {}
|
||||
[Error::OutputDiffers { .. }, Error::PatternNotFound { .. }] => {}
|
||||
_ => panic!("not the expected error: {:#?}", errors),
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user