Skip to content

Commit

Permalink
Auto merge of #9533 - Jarcho:integration-ice-msg, r=llogiq
Browse files Browse the repository at this point in the history
Fix panic when displaying the backtrace of failing integration tests

changelog: None
  • Loading branch information
bors committed Sep 25, 2022
2 parents 00ebd8e + 8493376 commit 57c9daa
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ use std::env;
use std::ffi::OsStr;
use std::process::Command;

#[cfg(not(windows))]
const CARGO_CLIPPY: &str = "cargo-clippy";
#[cfg(windows)]
const CARGO_CLIPPY: &str = "cargo-clippy.exe";

#[cfg_attr(feature = "integration", test)]
fn integration_test() {
let repo_name = env::var("INTEGRATION").expect("`INTEGRATION` var not set");
Expand All @@ -31,7 +36,7 @@ fn integration_test() {

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

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

let stderr = String::from_utf8_lossy(&output.stderr);
if stderr.contains("internal compiler error") {
let backtrace_start = stderr
.find("thread 'rustc' panicked at")
.expect("start of backtrace not found");
let backtrace_end = stderr
.rfind("error: internal compiler error")
if let Some(backtrace_start) = stderr.find("error: internal compiler error") {
static BACKTRACE_END_MSG: &str = "end of query stack";
let backtrace_end = stderr[backtrace_start..]
.find(BACKTRACE_END_MSG)
.expect("end of backtrace not found");

panic!(
"internal compiler error\nBacktrace:\n\n{}",
&stderr[backtrace_start..backtrace_end]
&stderr[backtrace_start..backtrace_start + backtrace_end + BACKTRACE_END_MSG.len()]
);
} else if stderr.contains("query stack during panic") {
panic!("query stack during panic in the output");
Expand Down

0 comments on commit 57c9daa

Please sign in to comment.