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 output = miri.output().expect("could not execute miri");
|
||||||
let mut errors = config.mode.ok(output.status);
|
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.
|
// Always remove annotation comments from stderr.
|
||||||
let annotations = Regex::new(r"\s*//~.*").unwrap();
|
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 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)
|
// Check output files (if any)
|
||||||
let revised = |extension: &str| {
|
let revised = |extension: &str| {
|
||||||
if revision.is_empty() {
|
if revision.is_empty() {
|
||||||
@ -252,7 +275,7 @@ fn run_test(
|
|||||||
check_output(
|
check_output(
|
||||||
&stderr,
|
&stderr,
|
||||||
path,
|
path,
|
||||||
&mut errors,
|
errors,
|
||||||
revised("stderr"),
|
revised("stderr"),
|
||||||
target,
|
target,
|
||||||
&config.stderr_filters,
|
&config.stderr_filters,
|
||||||
@ -262,7 +285,7 @@ fn run_test(
|
|||||||
check_output(
|
check_output(
|
||||||
&stdout,
|
&stdout,
|
||||||
path,
|
path,
|
||||||
&mut errors,
|
errors,
|
||||||
revised("stdout"),
|
revised("stdout"),
|
||||||
target,
|
target,
|
||||||
&config.stdout_filters,
|
&config.stdout_filters,
|
||||||
@ -270,8 +293,7 @@ fn run_test(
|
|||||||
comments,
|
comments,
|
||||||
);
|
);
|
||||||
// Check error annotations in the source against output
|
// Check error annotations in the source against output
|
||||||
check_annotations(&stderr, &mut errors, config, revision, comments);
|
check_annotations(&stderr, errors, config, revision, comments);
|
||||||
(miri, errors)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_annotations(
|
fn check_annotations(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use super::{check_annotations, Comments, Config, Error, Mode, OutputConflictHandling};
|
use super::*;
|
||||||
|
|
||||||
fn config() -> Config {
|
fn config() -> Config {
|
||||||
Config {
|
Config {
|
||||||
@ -8,7 +8,7 @@ fn config() -> Config {
|
|||||||
target: None,
|
target: None,
|
||||||
stderr_filters: vec![],
|
stderr_filters: vec![],
|
||||||
stdout_filters: vec![],
|
stdout_filters: vec![],
|
||||||
root_dir: PathBuf::from("."),
|
root_dir: PathBuf::from("$RUSTROOT"),
|
||||||
mode: Mode::Fail,
|
mode: Mode::Fail,
|
||||||
path_filter: vec![],
|
path_filter: vec![],
|
||||||
program: PathBuf::from("cake"),
|
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 _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 mut errors = vec![];
|
||||||
let config = config();
|
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)
|
error: Undefined Behavior: type validation failed: encountered a dangling reference (address 0x10 is unallocated)
|
||||||
--> tests/compile-fail/validity/dangling_ref1.rs:6:29
|
--> tests/compile-fail/validity/dangling_ref1.rs:6:29
|
||||||
|
|
|
|
||||||
@ -42,9 +44,10 @@ LL | let _x: &i32 = unsafe { mem::transmute(16usize) }; //~ ERROR encountere
|
|||||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||||
error: aborting due to previous error
|
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[..] {
|
match &errors[..] {
|
||||||
[Error::PatternNotFound { .. }] => {}
|
[Error::OutputDiffers { .. }, Error::PatternNotFound { .. }] => {}
|
||||||
_ => panic!("not the expected error: {:#?}", errors),
|
_ => panic!("not the expected error: {:#?}", errors),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user