Skip to content

Commit 7a766a4

Browse files
authored
Rollup merge of rust-lang#45722 - mikhail-m1:improve-mir-opt-error-output, r=alexcrichton
improve compiletest output for errors from mir-opt tests improvement: 1. Report filename against general cannot open error 2. Report current MIR block
2 parents ff00a5f + d6dfec1 commit 7a766a4

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/tools/compiletest/src/runtest.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,10 @@ actual:\n\
22862286
output_file.push(test_name);
22872287
debug!("comparing the contests of: {:?}", output_file);
22882288
debug!("with: {:?}", expected_content);
2289+
if !output_file.exists() {
2290+
panic!("Output file `{}` from test does not exist",
2291+
output_file.into_os_string().to_string_lossy());
2292+
}
22892293
self.check_mir_test_timestamp(test_name, &output_file);
22902294

22912295
let mut dumped_file = fs::File::open(output_file.clone()).unwrap();
@@ -2334,13 +2338,22 @@ actual:\n\
23342338

23352339
// We expect each non-empty line to appear consecutively, non-consecutive lines
23362340
// must be separated by at least one Elision
2341+
let mut start_block_line = None;
23372342
while let Some(dumped_line) = dumped_lines.next() {
23382343
match expected_lines.next() {
2339-
Some(&ExpectedLine::Text(expected_line)) =>
2344+
Some(&ExpectedLine::Text(expected_line)) => {
2345+
let normalized_expected_line = normalize_mir_line(expected_line);
2346+
if normalized_expected_line.contains(":{") {
2347+
start_block_line = Some(expected_line);
2348+
}
2349+
23402350
if !compare(expected_line, dumped_line) {
2351+
error!("{:?}", start_block_line);
23412352
error(expected_line,
2342-
format!("Mismatch in lines\nExpected Line: {:?}", dumped_line));
2343-
},
2353+
format!("Mismatch in lines\nCurrnt block: {}\nExpected Line: {:?}",
2354+
start_block_line.unwrap_or("None"), dumped_line));
2355+
}
2356+
},
23442357
Some(&ExpectedLine::Elision) => {
23452358
// skip any number of elisions in a row.
23462359
while let Some(&&ExpectedLine::Elision) = expected_lines.peek() {

0 commit comments

Comments
 (0)