Auto merge of #9039 - Serial-ATA:dev-dogfood, r=giraffate
Add `cargo dev dogfood` changelog: Add `cargo dev dogfood` Part of #5394
This commit is contained in:
@@ -59,7 +59,7 @@ cargo uitest
|
|||||||
# only run UI tests starting with `test_`
|
# only run UI tests starting with `test_`
|
||||||
TESTNAME="test_" cargo uitest
|
TESTNAME="test_" cargo uitest
|
||||||
# only run dogfood tests
|
# only run dogfood tests
|
||||||
cargo test --test dogfood
|
cargo dev dogfood
|
||||||
```
|
```
|
||||||
|
|
||||||
If the output of a [UI test] differs from the expected output, you can update
|
If the output of a [UI test] differs from the expected output, you can update
|
||||||
@@ -97,6 +97,8 @@ cargo dev deprecate
|
|||||||
cargo dev setup git-hook
|
cargo dev setup git-hook
|
||||||
# (experimental) Setup Clippy to work with IntelliJ-Rust
|
# (experimental) Setup Clippy to work with IntelliJ-Rust
|
||||||
cargo dev setup intellij
|
cargo dev setup intellij
|
||||||
|
# runs the `dogfood` tests
|
||||||
|
cargo dev dogfood
|
||||||
```
|
```
|
||||||
|
|
||||||
More about intellij command usage and reasons
|
More about intellij command usage and reasons
|
||||||
|
|||||||
33
clippy_dev/src/dogfood.rs
Normal file
33
clippy_dev/src/dogfood.rs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
use crate::clippy_project_root;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if unable to run the dogfood test
|
||||||
|
pub fn dogfood(fix: bool, allow_dirty: bool, allow_staged: bool) {
|
||||||
|
let mut cmd = Command::new("cargo");
|
||||||
|
|
||||||
|
cmd.current_dir(clippy_project_root())
|
||||||
|
.args(["test", "--test", "dogfood"])
|
||||||
|
.args(["--features", "internal"])
|
||||||
|
.args(["--", "dogfood_clippy"]);
|
||||||
|
|
||||||
|
let mut dogfood_args = Vec::new();
|
||||||
|
if fix {
|
||||||
|
dogfood_args.push("--fix");
|
||||||
|
}
|
||||||
|
|
||||||
|
if allow_dirty {
|
||||||
|
dogfood_args.push("--allow-dirty");
|
||||||
|
}
|
||||||
|
|
||||||
|
if allow_staged {
|
||||||
|
dogfood_args.push("--allow-staged");
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.env("__CLIPPY_DOGFOOD_ARGS", dogfood_args.join(" "));
|
||||||
|
|
||||||
|
let output = cmd.output().expect("failed to run command");
|
||||||
|
|
||||||
|
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ extern crate rustc_lexer;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub mod bless;
|
pub mod bless;
|
||||||
|
pub mod dogfood;
|
||||||
pub mod fmt;
|
pub mod fmt;
|
||||||
pub mod lint;
|
pub mod lint;
|
||||||
pub mod new_lint;
|
pub mod new_lint;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#![warn(rust_2018_idioms, unused_lifetimes)]
|
#![warn(rust_2018_idioms, unused_lifetimes)]
|
||||||
|
|
||||||
use clap::{Arg, ArgAction, ArgMatches, Command, PossibleValue};
|
use clap::{Arg, ArgAction, ArgMatches, Command, PossibleValue};
|
||||||
use clippy_dev::{bless, fmt, lint, new_lint, serve, setup, update_lints};
|
use clippy_dev::{bless, dogfood, fmt, lint, new_lint, serve, setup, update_lints};
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -13,6 +13,13 @@ fn main() {
|
|||||||
Some(("bless", matches)) => {
|
Some(("bless", matches)) => {
|
||||||
bless::bless(matches.contains_id("ignore-timestamp"));
|
bless::bless(matches.contains_id("ignore-timestamp"));
|
||||||
},
|
},
|
||||||
|
Some(("dogfood", matches)) => {
|
||||||
|
dogfood::dogfood(
|
||||||
|
matches.contains_id("fix"),
|
||||||
|
matches.contains_id("allow-dirty"),
|
||||||
|
matches.contains_id("allow-staged"),
|
||||||
|
);
|
||||||
|
},
|
||||||
Some(("fmt", matches)) => {
|
Some(("fmt", matches)) => {
|
||||||
fmt::run(matches.contains_id("check"), matches.contains_id("verbose"));
|
fmt::run(matches.contains_id("check"), matches.contains_id("verbose"));
|
||||||
},
|
},
|
||||||
@@ -104,6 +111,17 @@ fn get_clap_config() -> ArgMatches {
|
|||||||
.long("ignore-timestamp")
|
.long("ignore-timestamp")
|
||||||
.help("Include files updated before clippy was built"),
|
.help("Include files updated before clippy was built"),
|
||||||
),
|
),
|
||||||
|
Command::new("dogfood").about("Runs the dogfood test").args([
|
||||||
|
Arg::new("fix").long("fix").help("Apply the suggestions when possible"),
|
||||||
|
Arg::new("allow-dirty")
|
||||||
|
.long("allow-dirty")
|
||||||
|
.help("Fix code even if the working directory has changes")
|
||||||
|
.requires("fix"),
|
||||||
|
Arg::new("allow-staged")
|
||||||
|
.long("allow-staged")
|
||||||
|
.help("Fix code even if the working directory has staged changes")
|
||||||
|
.requires("fix"),
|
||||||
|
]),
|
||||||
Command::new("fmt")
|
Command::new("fmt")
|
||||||
.about("Run rustfmt on all projects and tests")
|
.about("Run rustfmt on all projects and tests")
|
||||||
.args([
|
.args([
|
||||||
|
|||||||
@@ -74,10 +74,16 @@ fn run_clippy_for_package(project: &str, args: &[&str]) {
|
|||||||
.env("CARGO_INCREMENTAL", "0")
|
.env("CARGO_INCREMENTAL", "0")
|
||||||
.arg("clippy")
|
.arg("clippy")
|
||||||
.arg("--all-targets")
|
.arg("--all-targets")
|
||||||
.arg("--all-features")
|
.arg("--all-features");
|
||||||
.arg("--")
|
|
||||||
.args(args)
|
if let Ok(dogfood_args) = std::env::var("__CLIPPY_DOGFOOD_ARGS") {
|
||||||
.arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
|
for arg in dogfood_args.split_whitespace() {
|
||||||
|
command.arg(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
command.arg("--").args(args);
|
||||||
|
command.arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
|
||||||
|
|
||||||
if cfg!(feature = "internal") {
|
if cfg!(feature = "internal") {
|
||||||
// internal lints only exist if we build with the internal feature
|
// internal lints only exist if we build with the internal feature
|
||||||
|
|||||||
Reference in New Issue
Block a user