-
Notifications
You must be signed in to change notification settings - Fork 1.7k
RIIR: Integration tests #4837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
RIIR: Integration tests #4837
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3e1139a
Rust implementation of integration test
flip1995 21e81f1
Use rust implementation for integration tests in CI
flip1995 6271631
Remove the old integration-tests.sh script
flip1995 a6289cc
Revert "Disable chalk integration test. Output too large"
flip1995 82066d2
Use `println!` on success instead of `eprintln!`
flip1995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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"), | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.