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