#![warn(rust_2018_idioms, unused_lifetimes)]
#![allow(clippy::single_match_else)]
-use rustc_tools_util::VersionInfo;
use std::fs;
#[test]
-fn check_that_clippy_lints_and_clippy_utils_have_the_same_version_as_clippy() {
+fn consistent_clippy_crate_versions() {
fn read_version(path: &str) -> String {
- let contents = fs::read_to_string(path).unwrap_or_else(|e| panic!("error reading `{}`: {:?}", path, e));
+ let contents = fs::read_to_string(path).unwrap_or_else(|e| panic!("error reading `{path}`: {e:?}"));
contents
.lines()
.filter_map(|l| l.split_once('='))
.find_map(|(k, v)| (k.trim() == "version").then(|| v.trim()))
- .unwrap_or_else(|| panic!("error finding version in `{}`", path))
+ .unwrap_or_else(|| panic!("error finding version in `{path}`"))
.to_string()
}
}
let clippy_version = read_version("Cargo.toml");
- let clippy_lints_version = read_version("clippy_lints/Cargo.toml");
- let clippy_utils_version = read_version("clippy_utils/Cargo.toml");
- assert_eq!(clippy_version, clippy_lints_version);
- assert_eq!(clippy_version, clippy_utils_version);
+ let paths = [
+ "declare_clippy_lint/Cargo.toml",
+ "clippy_lints/Cargo.toml",
+ "clippy_utils/Cargo.toml",
+ ];
+
+ for path in paths {
+ assert_eq!(clippy_version, read_version(path), "{path} version differs");
+ }
}
#[test]
// `RUSTC_REAL` if Clippy is build in the Rust repo with `./x.py`.
let rustc = std::env::var("RUSTC_REAL").unwrap_or_else(|_| "rustc".to_string());
let rustc_version = String::from_utf8(
- std::process::Command::new(&rustc)
+ std::process::Command::new(rustc)
.arg("--version")
.output()
.expect("failed to run `rustc --version`")
// we don't want our tests failing suddenly
},
_ => {
- panic!("Failed to parse rustc version: {:?}", vsplit);
+ panic!("Failed to parse rustc version: {vsplit:?}");
},
};
}