diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-12-20 11:16:30 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-20 11:16:30 -0800 |
| commit | dfa9948d76ecaa4bf7b03df668f1dde8884325b1 (patch) | |
| tree | d351fab41f6a19686fb36f4fd9cc129a6f66eb17 /src | |
| parent | 2f4ca4e2dfed77cd3b4785a616be3d12112fc41e (diff) | |
| parent | 90c5b7187cf2d30e90f1023d9d78d0a9f33669a2 (diff) | |
| download | rust-dfa9948d76ecaa4bf7b03df668f1dde8884325b1.tar.gz rust-dfa9948d76ecaa4bf7b03df668f1dde8884325b1.zip | |
Rollup merge of #38289 - bluss:mir-verbose-test-fail, r=michaelwoerister
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')
| -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, "") + } } |
