Improve tests

This commit is contained in:
Samuel E. Moelius III 2021-02-17 12:30:48 -05:00
parent b7f03c6697
commit ff157ae1f4
2 changed files with 16 additions and 13 deletions

View File

@ -1,7 +1,7 @@
[package]
name = "clippy_utils"
version = "0.1.0"
authors = ["The Rust Project Developers"]
version = "0.1.51"
authors = ["The Rust Clippy Developers"]
edition = "2018"
[dependencies]

View File

@ -2,21 +2,24 @@
use rustc_tools_util::VersionInfo;
#[test]
fn check_that_clippy_lints_has_the_same_version_as_clippy() {
fn check_that_clippy_lints_and_clippy_utils_have_the_same_version_as_clippy() {
let clippy_meta = cargo_metadata::MetadataCommand::new()
.no_deps()
.exec()
.expect("could not obtain cargo metadata");
std::env::set_current_dir(std::env::current_dir().unwrap().join("clippy_lints")).unwrap();
let clippy_lints_meta = cargo_metadata::MetadataCommand::new()
.no_deps()
.exec()
.expect("could not obtain cargo metadata");
assert_eq!(clippy_lints_meta.packages[0].version, clippy_meta.packages[0].version);
for package in &clippy_meta.packages[0].dependencies {
if package.name == "clippy_lints" {
assert!(package.req.matches(&clippy_lints_meta.packages[0].version));
return;
for krate in &["clippy_lints", "clippy_utils"] {
let krate_meta = cargo_metadata::MetadataCommand::new()
.current_dir(std::env::current_dir().unwrap().join(krate))
.no_deps()
.exec()
.expect("could not obtain cargo metadata");
assert_eq!(krate_meta.packages[0].version, clippy_meta.packages[0].version);
for package in &clippy_meta.packages[0].dependencies {
if package.name == *krate {
assert!(package.req.matches(&krate_meta.packages[0].version));
break;
}
}
}
}