1 #![cfg(feature = "integration")]
6 use std::process::Command;
8 #[cfg_attr(feature = "integration", test)]
9 fn integration_test() {
10 let repo_name = env::var("INTEGRATION").expect("`INTEGRATION` var not set");
11 let repo_url = format!("https://github.com/{}", repo_name);
12 let crate_name = repo_name
15 .expect("repo name should have format `<org>/<name>`");
17 let repo_dir = tempfile::tempdir()
18 .expect("couldn't create temp dir")
22 Repository::clone(&repo_url, &repo_dir).expect("clone of repo failed");
24 let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
25 let target_dir = std::path::Path::new(&root_dir).join("target");
26 let clippy_binary = target_dir.join(env!("PROFILE")).join("cargo-clippy");
28 let output = Command::new(clippy_binary)
29 .current_dir(repo_dir)
30 .env("RUST_BACKTRACE", "full")
31 .env("CARGO_TARGET_DIR", target_dir)
43 .expect("unable to run clippy");
45 let stderr = String::from_utf8_lossy(&output.stderr);
46 if stderr.contains("internal compiler error") {
47 let backtrace_start = stderr
48 .find("thread 'rustc' panicked at")
49 .expect("start of backtrace not found");
50 let backtrace_end = stderr
51 .rfind("error: internal compiler error")
52 .expect("end of backtrace not found");
55 "internal compiler error\nBacktrace:\n\n{}",
56 &stderr[backtrace_start..backtrace_end]
58 } else if stderr.contains("query stack during panic") {
59 panic!("query stack during panic in the output");
60 } else if stderr.contains("E0463") {
61 panic!("error: E0463");
64 match output.status.code() {
67 println!("Compilation successful");
69 eprintln!("Compilation failed. Exit code: {}", code);
72 None => panic!("Process terminated by signal"),