|
1 | | -use crate::utils::exit_if_err; |
| 1 | +use crate::utils::run_exit_on_err; |
| 2 | +use itertools::Itertools; |
2 | 3 | use std::process::Command; |
3 | 4 |
|
4 | 5 | /// # Panics |
5 | 6 | /// |
6 | 7 | /// Panics if unable to run the dogfood test |
7 | 8 | #[allow(clippy::fn_params_excessive_bools)] |
8 | 9 | pub fn dogfood(fix: bool, allow_dirty: bool, allow_staged: bool, allow_no_vcs: bool) { |
9 | | - let mut cmd = Command::new("cargo"); |
10 | | - |
11 | | - cmd.args(["test", "--test", "dogfood"]) |
12 | | - .args(["--features", "internal"]) |
13 | | - .args(["--", "dogfood_clippy", "--nocapture"]); |
14 | | - |
15 | | - let mut dogfood_args = Vec::new(); |
16 | | - if fix { |
17 | | - dogfood_args.push("--fix"); |
18 | | - } |
19 | | - |
20 | | - if allow_dirty { |
21 | | - dogfood_args.push("--allow-dirty"); |
22 | | - } |
23 | | - |
24 | | - if allow_staged { |
25 | | - dogfood_args.push("--allow-staged"); |
26 | | - } |
27 | | - |
28 | | - if allow_no_vcs { |
29 | | - dogfood_args.push("--allow-no-vcs"); |
30 | | - } |
31 | | - |
32 | | - cmd.env("__CLIPPY_DOGFOOD_ARGS", dogfood_args.join(" ")); |
33 | | - |
34 | | - exit_if_err(cmd.status()); |
| 10 | + run_exit_on_err( |
| 11 | + "cargo test", |
| 12 | + Command::new("cargo") |
| 13 | + .args(["test", "--test", "dogfood"]) |
| 14 | + .args(["--features", "internal"]) |
| 15 | + .args(["--", "dogfood_clippy", "--nocapture"]) |
| 16 | + .env( |
| 17 | + "__CLIPPY_DOGFOOD_ARGS", |
| 18 | + [ |
| 19 | + if fix { "--fix" } else { "" }, |
| 20 | + if allow_dirty { "--allow-dirty" } else { "" }, |
| 21 | + if allow_staged { "--allow-staged" } else { "" }, |
| 22 | + if allow_no_vcs { "--allow-no-vcs" } else { "" }, |
| 23 | + ] |
| 24 | + .iter() |
| 25 | + .filter(|x| !x.is_empty()) |
| 26 | + .join(" "), |
| 27 | + ), |
| 28 | + ); |
35 | 29 | } |
0 commit comments