Skip to content

Commit

Permalink
lintcheck: env var LINTCHECK_TOML can be used to override toml file l…
Browse files Browse the repository at this point in the history
…ocation (has precedence over --crates-toml flag)
  • Loading branch information
matthiaskrgr committed Feb 12, 2021
1 parent 047f3e1 commit 5bbb1bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clippy_dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cargo dev-lintcheck

By default the logs will be saved into `lintcheck-logs/lintcheck_crates_logs.txt`.

You can set a custom sources.toml by adding `--crates-toml custom.toml`
You can set a custom sources.toml by adding `--crates-toml custom.toml` or using `LINTCHECK_TOML="custom.toml"`
where `custom.toml` must be a relative path from the repo root.

The results will then be saved to `lintcheck-logs/custom_logs.toml`.
Expand Down
6 changes: 4 additions & 2 deletions clippy_dev/src/lintcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::clippy_project_root;

use std::collections::HashMap;
use std::process::Command;
use std::{fmt, fs::write, path::PathBuf};
use std::{env, fmt, fs::write, path::PathBuf};

use clap::ArgMatches;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -227,7 +227,9 @@ fn build_clippy() {

// get a list of CrateSources we want to check from a "lintcheck_crates.toml" file.
fn read_crates(toml_path: Option<&str>) -> (String, Vec<CrateSource>) {
let toml_path = PathBuf::from(toml_path.unwrap_or("clippy_dev/lintcheck_crates.toml"));
let toml_path = PathBuf::from(
env::var("LINTCHECK_TOML").unwrap_or(toml_path.unwrap_or("clippy_dev/lintcheck_crates.toml").to_string()),
);
// save it so that we can use the name of the sources.toml as name for the logfile later.
let toml_filename = toml_path.file_stem().unwrap().to_str().unwrap().to_string();
let toml_content: String =
Expand Down

0 comments on commit 5bbb1bc

Please sign in to comment.