Skip to content

Commit 57c9daa

Browse files
committed
Auto merge of #9533 - Jarcho:integration-ice-msg, r=llogiq
Fix panic when displaying the backtrace of failing integration tests changelog: None
2 parents 00ebd8e + 8493376 commit 57c9daa

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

tests/integration.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ use std::env;
66
use std::ffi::OsStr;
77
use std::process::Command;
88

9+
#[cfg(not(windows))]
10+
const CARGO_CLIPPY: &str = "cargo-clippy";
11+
#[cfg(windows)]
12+
const CARGO_CLIPPY: &str = "cargo-clippy.exe";
13+
914
#[cfg_attr(feature = "integration", test)]
1015
fn integration_test() {
1116
let repo_name = env::var("INTEGRATION").expect("`INTEGRATION` var not set");
@@ -31,7 +36,7 @@ fn integration_test() {
3136

3237
let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
3338
let target_dir = std::path::Path::new(&root_dir).join("target");
34-
let clippy_binary = target_dir.join(env!("PROFILE")).join("cargo-clippy");
39+
let clippy_binary = target_dir.join(env!("PROFILE")).join(CARGO_CLIPPY);
3540

3641
let output = Command::new(clippy_binary)
3742
.current_dir(repo_dir)
@@ -51,17 +56,15 @@ fn integration_test() {
5156
.expect("unable to run clippy");
5257

5358
let stderr = String::from_utf8_lossy(&output.stderr);
54-
if stderr.contains("internal compiler error") {
55-
let backtrace_start = stderr
56-
.find("thread 'rustc' panicked at")
57-
.expect("start of backtrace not found");
58-
let backtrace_end = stderr
59-
.rfind("error: internal compiler error")
59+
if let Some(backtrace_start) = stderr.find("error: internal compiler error") {
60+
static BACKTRACE_END_MSG: &str = "end of query stack";
61+
let backtrace_end = stderr[backtrace_start..]
62+
.find(BACKTRACE_END_MSG)
6063
.expect("end of backtrace not found");
6164

6265
panic!(
6366
"internal compiler error\nBacktrace:\n\n{}",
64-
&stderr[backtrace_start..backtrace_end]
67+
&stderr[backtrace_start..backtrace_start + backtrace_end + BACKTRACE_END_MSG.len()]
6568
);
6669
} else if stderr.contains("query stack during panic") {
6770
panic!("query stack during panic in the output");

0 commit comments

Comments
 (0)