1 #![cfg(feature = "integration")]
4 use std::process::Command;
6 #[cfg_attr(feature = "integration", test)]
7 fn integration_test() {
8 let repo_name = env::var("INTEGRATION").expect("`INTEGRATION` var not set");
9 let repo_url = format!("https://github.com/{}", repo_name);
10 let crate_name = repo_name
13 .expect("repo name should have format `<org>/<name>`");
15 let repo_dir = tempfile::tempdir()
16 .expect("couldn't create temp dir")
20 let st = Command::new("git")
21 .args(&["clone", "--depth=1", &repo_url, repo_dir.to_str().unwrap()])
23 .expect("unable to run git");
24 assert!(st.success());
26 let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
27 let target_dir = std::path::Path::new(&root_dir).join("target");
28 let clippy_binary = target_dir.join(env!("PROFILE")).join("cargo-clippy");
30 let output = Command::new(clippy_binary)
31 .current_dir(repo_dir)
32 .env("RUST_BACKTRACE", "full")
33 .env("CARGO_TARGET_DIR", target_dir)
45 .expect("unable to run clippy");
47 let stderr = String::from_utf8_lossy(&output.stderr);
48 if stderr.contains("internal compiler error") {
49 let backtrace_start = stderr
50 .find("thread 'rustc' panicked at")
51 .expect("start of backtrace not found");
52 let backtrace_end = stderr
53 .rfind("error: internal compiler error")
54 .expect("end of backtrace not found");
57 "internal compiler error\nBacktrace:\n\n{}",
58 &stderr[backtrace_start..backtrace_end]
60 } else if stderr.contains("query stack during panic") {
61 panic!("query stack during panic in the output");
62 } else if stderr.contains("E0463") {
63 panic!("error: E0463");
64 } else if stderr.contains("E0514") {
65 panic!("incompatible crate versions");
66 } else if stderr.contains("failed to run `rustc` to learn about target-specific information") {
67 panic!("couldn't find librustc_driver, consider setting `LD_LIBRARY_PATH`");
70 match output.status.code() {
73 println!("Compilation successful");
75 eprintln!("Compilation failed. Exit code: {}", code);
78 None => panic!("Process terminated by signal"),