Check $CARGO before $PATH
This commit is contained in:
parent
1c8cbe79ab
commit
9083b52122
@ -1,6 +1,6 @@
|
|||||||
use crate::{cargo_clippy_path, exit_if_err};
|
use crate::{cargo_clippy_path, exit_if_err};
|
||||||
use std::fs;
|
|
||||||
use std::process::{self, Command};
|
use std::process::{self, Command};
|
||||||
|
use std::{env, fs};
|
||||||
|
|
||||||
pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
|
pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
|
||||||
let is_file = match fs::metadata(path) {
|
let is_file = match fs::metadata(path) {
|
||||||
@ -13,7 +13,7 @@ pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
|
|||||||
|
|
||||||
if is_file {
|
if is_file {
|
||||||
exit_if_err(
|
exit_if_err(
|
||||||
Command::new("cargo")
|
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
|
||||||
.args(["run", "--bin", "clippy-driver", "--"])
|
.args(["run", "--bin", "clippy-driver", "--"])
|
||||||
.args(["-L", "./target/debug"])
|
.args(["-L", "./target/debug"])
|
||||||
.args(["-Z", "no-codegen"])
|
.args(["-Z", "no-codegen"])
|
||||||
@ -23,7 +23,11 @@ pub fn run<'a>(path: &str, args: impl Iterator<Item = &'a String>) {
|
|||||||
.status(),
|
.status(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
exit_if_err(Command::new("cargo").arg("build").status());
|
exit_if_err(
|
||||||
|
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
|
||||||
|
.arg("build")
|
||||||
|
.status(),
|
||||||
|
);
|
||||||
|
|
||||||
let status = Command::new(cargo_clippy_path())
|
let status = Command::new(cargo_clippy_path())
|
||||||
.arg("clippy")
|
.arg("clippy")
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
use std::num::ParseIntError;
|
use std::num::ParseIntError;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::thread;
|
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
|
use std::{env, thread};
|
||||||
|
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
@ -16,7 +16,7 @@ pub fn run(port: u16, lint: Option<&String>) -> ! {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
if mtime("util/gh-pages/lints.json") < mtime("clippy_lints/src") {
|
if mtime("util/gh-pages/lints.json") < mtime("clippy_lints/src") {
|
||||||
Command::new("cargo")
|
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
|
||||||
.arg("collect-metadata")
|
.arg("collect-metadata")
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -28,12 +28,12 @@
|
|||||||
use serde::ser::SerializeStruct;
|
use serde::ser::SerializeStruct;
|
||||||
use serde::{Serialize, Serializer};
|
use serde::{Serialize, Serializer};
|
||||||
use std::collections::{BTreeSet, BinaryHeap};
|
use std::collections::{BTreeSet, BinaryHeap};
|
||||||
use std::fmt;
|
|
||||||
use std::fmt::Write as _;
|
use std::fmt::Write as _;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
use std::{env, fmt};
|
||||||
|
|
||||||
/// This is the json output file of the lint collector.
|
/// This is the json output file of the lint collector.
|
||||||
const JSON_OUTPUT_FILE: &str = "../util/gh-pages/lints.json";
|
const JSON_OUTPUT_FILE: &str = "../util/gh-pages/lints.json";
|
||||||
@ -415,7 +415,7 @@ fn get_lint_output(lint_name: &str, example: &[&mut String], clippy_project_root
|
|||||||
|
|
||||||
let prefixed_name = format!("{CLIPPY_LINT_GROUP_PREFIX}{lint_name}");
|
let prefixed_name = format!("{CLIPPY_LINT_GROUP_PREFIX}{lint_name}");
|
||||||
|
|
||||||
let mut cmd = Command::new("cargo");
|
let mut cmd = Command::new(env::var("CARGO").unwrap_or("cargo".into()));
|
||||||
|
|
||||||
cmd.current_dir(clippy_project_root)
|
cmd.current_dir(clippy_project_root)
|
||||||
.env("CARGO_INCREMENTAL", "0")
|
.env("CARGO_INCREMENTAL", "0")
|
||||||
|
@ -367,7 +367,7 @@ fn run_clippy_lints(
|
|||||||
//
|
//
|
||||||
// The wrapper is set to the `lintcheck` so we can force enable linting and ignore certain crates
|
// The wrapper is set to the `lintcheck` so we can force enable linting and ignore certain crates
|
||||||
// (see `crate::driver`)
|
// (see `crate::driver`)
|
||||||
let status = Command::new("cargo")
|
let status = Command::new(env::var("CARGO").unwrap_or("cargo".into()))
|
||||||
.arg("check")
|
.arg("check")
|
||||||
.arg("--quiet")
|
.arg("--quiet")
|
||||||
.current_dir(&self.path)
|
.current_dir(&self.path)
|
||||||
@ -441,7 +441,7 @@ fn run_clippy_lints(
|
|||||||
|
|
||||||
/// Builds clippy inside the repo to make sure we have a clippy executable we can use.
|
/// Builds clippy inside the repo to make sure we have a clippy executable we can use.
|
||||||
fn build_clippy() {
|
fn build_clippy() {
|
||||||
let status = Command::new("cargo")
|
let status = Command::new(env::var("CARGO").unwrap_or("cargo".into()))
|
||||||
.arg("build")
|
.arg("build")
|
||||||
.status()
|
.status()
|
||||||
.expect("Failed to build clippy!");
|
.expect("Failed to build clippy!");
|
||||||
@ -816,7 +816,7 @@ fn lintcheck_test() {
|
|||||||
"--crates-toml",
|
"--crates-toml",
|
||||||
"lintcheck/test_sources.toml",
|
"lintcheck/test_sources.toml",
|
||||||
];
|
];
|
||||||
let status = std::process::Command::new("cargo")
|
let status = std::process::Command::new(env::var("CARGO").unwrap_or("cargo".into()))
|
||||||
.args(args)
|
.args(args)
|
||||||
.current_dir("..") // repo root
|
.current_dir("..") // repo root
|
||||||
.status();
|
.status();
|
||||||
|
@ -105,7 +105,7 @@ fn path() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn into_std_cmd(self) -> Command {
|
fn into_std_cmd(self) -> Command {
|
||||||
let mut cmd = Command::new("cargo");
|
let mut cmd = Command::new(env::var("CARGO").unwrap_or("cargo".into()));
|
||||||
let clippy_args: String = self
|
let clippy_args: String = self
|
||||||
.clippy_args
|
.clippy_args
|
||||||
.iter()
|
.iter()
|
||||||
|
Loading…
Reference in New Issue
Block a user