-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): enforce crate directory name match + take version from wor…
…kspace (#2014) Signed-off-by: Dori Medini <[email protected]>
- Loading branch information
1 parent
3c69ac8
commit f8e9dc1
Showing
6 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#![cfg(test)] | ||
|
||
pub mod lints_test; | ||
pub mod package_integrity_test; | ||
pub mod toml_utils; | ||
pub mod version_integrity_test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use std::path::PathBuf; | ||
|
||
use crate::toml_utils::{PackageEntryValue, ROOT_TOML}; | ||
|
||
#[test] | ||
fn test_package_names_match_directory() { | ||
let mismatched_packages: Vec<_> = ROOT_TOML | ||
.member_cargo_tomls() | ||
.into_iter() | ||
.filter_map(|(path_str, toml)| { | ||
let path = PathBuf::from(&path_str); | ||
let directory_name = path.file_name()?.to_str()?; | ||
match toml.package.get("name") { | ||
Some(PackageEntryValue::String(package_name)) if package_name == directory_name => { | ||
None | ||
} | ||
_ => Some(path_str), | ||
} | ||
}) | ||
.collect(); | ||
assert!( | ||
mismatched_packages.is_empty(), | ||
"The following crates have package names that do not match their directory names, or are \ | ||
missing a name field: {mismatched_packages:?}." | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters