mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
4d1a11d354
If you've been using `./util/dev` before, this now becomes `cargo dev`. The key part of this change is found in `.cargo/config`. This means one less shell script and a bit more cross-platform support for contributors.
39 lines
1.2 KiB
Rust
39 lines
1.2 KiB
Rust
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
#[test]
|
|
fn fmt() {
|
|
if option_env!("RUSTC_TEST_SUITE").is_some() {
|
|
return;
|
|
}
|
|
|
|
// Skip this test if rustup nightly is unavailable
|
|
let rustup_output = Command::new("rustup")
|
|
.args(&["component", "list", "--toolchain", "nightly"])
|
|
.output()
|
|
.unwrap();
|
|
assert!(rustup_output.status.success());
|
|
let component_output = String::from_utf8_lossy(&rustup_output.stdout);
|
|
if !component_output.contains("rustfmt") {
|
|
return;
|
|
}
|
|
|
|
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
let dev_dir = root_dir.join("clippy_dev");
|
|
let target_dir = root_dir.join("target");
|
|
let target_dir = target_dir.to_str().unwrap();
|
|
let output = Command::new("cargo")
|
|
.current_dir(dev_dir)
|
|
.args(&["+nightly", "run", "--target-dir", target_dir, "--", "fmt", "--check"])
|
|
.output()
|
|
.unwrap();
|
|
|
|
println!("status: {}", output.status);
|
|
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
|
|
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
|
|
|
|
assert!(
|
|
output.status.success(),
|
|
"Formatting check failed. Run `cargo dev fmt` to update formatting."
|
|
);
|
|
}
|