diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-12-10 22:24:29 +0100 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-12-10 22:27:40 +0100 |
| commit | 90c5b7187cf2d30e90f1023d9d78d0a9f33669a2 (patch) | |
| tree | fddd06996e506dd882fbef98779e5c3e11eb6326 /src/tools/compiletest | |
| parent | dedd9850841f20880b6318ce9cbe60e2b205b6a9 (diff) | |
| download | rust-90c5b7187cf2d30e90f1023d9d78d0a9f33669a2.tar.gz rust-90c5b7187cf2d30e90f1023d9d78d0a9f33669a2.zip | |
compiletest: A more verbose matching failure for mir tests
This makes it easier to work with mir test failures during development. - Show which expected line was not found - Show full expected output - Show full actual output
Diffstat (limited to 'src/tools/compiletest')
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 3cc14541fcd..d65205fe65a 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2294,7 +2294,18 @@ actual:\n\ }; } if !found { - panic!("ran out of mir dump output to match against"); + let normalize_all = dumped_string.lines() + .map(nocomment_mir_line) + .filter(|l| !l.is_empty()) + .collect::<Vec<_>>() + .join("\n"); + panic!("ran out of mir dump output to match against.\n\ + Did not find expected line: {:?}\n\ + Expected:\n{}\n\ + Actual:\n{}", + expected_line, + expected_content.join("\n"), + normalize_all); } } } @@ -2439,11 +2450,14 @@ enum TargetLocation { } fn normalize_mir_line(line: &str) -> String { - let no_comments = if let Some(idx) = line.find("//") { + nocomment_mir_line(line).replace(char::is_whitespace, "") +} + +fn nocomment_mir_line(line: &str) -> &str { + if let Some(idx) = line.find("//") { let (l, _) = line.split_at(idx); - l + l.trim_right() } else { line - }; - no_comments.replace(char::is_whitespace, "") + } } |
