-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #4837 - flip1995:integration, r=<try>
RIIR: Integration tests In #4825 the `rust-lang/chalk` test failed because the output was too large. I didn't want to completely disabling the output, since showing the backtrace of an ICE directly in travis is pretty useful. Since finding strings in command outputs is easier in Rust, than in bash, I just RIIRed it. This and also rewriting our tests in Rust may help with trying out new CI platforms (cc #4577) changelog: none
- Loading branch information
Showing
4 changed files
with
83 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#![cfg(feature = "integration")] | ||
|
||
use git2::Repository; | ||
use tempfile; | ||
|
||
use std::env; | ||
use std::process::Command; | ||
|
||
#[cfg_attr(feature = "integration", test)] | ||
fn integration_test() { | ||
let repo_name = env::var("INTEGRATION").expect("`INTEGRATION` var not set"); | ||
let repo_url = format!("https://github.com/{}", repo_name); | ||
let crate_name = repo_name | ||
.split('/') | ||
.nth(1) | ||
.expect("repo name should have format `<org>/<name>`"); | ||
|
||
let repo_dir = tempfile::tempdir() | ||
.expect("couldn't create temp dir") | ||
.path() | ||
.join(crate_name); | ||
|
||
Repository::clone(&repo_url, &repo_dir).expect("clone of repo failed"); | ||
|
||
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 output = Command::new(clippy_binary) | ||
.current_dir(repo_dir) | ||
.env("RUST_BACKTRACE", "full") | ||
.env("CARGO_TARGET_DIR", target_dir) | ||
.args(&[ | ||
"clippy", | ||
"--all-targets", | ||
"--all-features", | ||
"--", | ||
"--cap-lints", | ||
"warn", | ||
"-Wclippy::pedantic", | ||
"-Wclippy::nursery", | ||
]) | ||
.output() | ||
.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") | ||
.expect("end of backtrace not found"); | ||
|
||
panic!( | ||
"internal compiler error\nBacktrace:\n\n{}", | ||
&stderr[backtrace_start..backtrace_end] | ||
); | ||
} else if stderr.contains("query stack during panic") { | ||
panic!("query stack during panic in the output"); | ||
} else if stderr.contains("E0463") { | ||
panic!("error: E0463"); | ||
} | ||
|
||
match output.status.code() { | ||
Some(code) => { | ||
if code == 0 { | ||
eprintln!("Compilation successful"); | ||
} else { | ||
eprintln!("Compilation failed. Exit code: {}", code); | ||
} | ||
}, | ||
None => panic!("Process terminated by signal"), | ||
} | ||
} |