diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-03-09 14:06:42 +0100 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2021-03-11 13:26:26 +0100 |
| commit | a846945b82f1bfe5f01aff6688927ddb5f4b2514 (patch) | |
| tree | 1560ec5a62113fbc19ad25c7cab6a5d2a758308c | |
| parent | 2546e6f006da4acc79dbed3711674e7d7b73f1f0 (diff) | |
| download | rust-a846945b82f1bfe5f01aff6688927ddb5f4b2514.tar.gz rust-a846945b82f1bfe5f01aff6688927ddb5f4b2514.zip | |
lintcheck: make sure we lauch from the repo root
This will terminate the program if run via "cargo run". "cargo run" does currently not work because at least a bunch of paths do not take that into account.
| -rw-r--r-- | lintcheck/src/main.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lintcheck/src/main.rs b/lintcheck/src/main.rs index f5a54cfa8dc..e6b2d49cfef 100644 --- a/lintcheck/src/main.rs +++ b/lintcheck/src/main.rs @@ -1,5 +1,6 @@ // Run clippy on a fixed set of crates and collect the warnings. -// This helps observing the impact clippy changes have on a set of real-world code (and not just our testsuite). +// This helps observing the impact clippy changes have on a set of real-world code (and not just our +// testsuite). // // When a new lint is introduced, we can search the results for new warnings and check for false // positives. @@ -556,12 +557,29 @@ fn lintcheck_needs_rerun(lintcheck_logs_path: &Path) -> bool { logs_modified < clippy_modified } +fn is_in_clippy_root() -> bool { + if let Ok(pb) = std::env::current_dir() { + if let Some(file) = pb.file_name() { + return file == PathBuf::from("rust-clippy"); + } + } + + false +} + /// lintchecks `main()` function /// /// # Panics /// -/// This function panics if the clippy binaries don't exist. +/// This function panics if the clippy binaries don't exist +/// or if lintcheck is executed from the wrong directory (aka none-repo-root) pub fn main() { + // assert that we launch lintcheck from the repo root (via cargo dev-lintcheck) + if !is_in_clippy_root() { + eprintln!("lintcheck needs to be run from clippys repo root!\nUse `cargo dev-lintcheck` alternatively."); + std::process::exit(3); + } + let clap_config = &get_clap_config(); let config = LintcheckConfig::from_clap(clap_config); |
