Add test for rule names

This commit is contained in:
Martin Fischer 2023-02-10 10:35:10 +01:00 committed by Charlie Marsh
parent 0bab642f5a
commit cba91b758b
2 changed files with 22 additions and 0 deletions

View file

@ -859,6 +859,28 @@ mod tests {
use super::{Linter, Rule, RuleNamespace}; use super::{Linter, Rule, RuleNamespace};
#[test]
fn test_rule_naming_convention() {
// The disallowed rule names are defined in a separate file so that they can also be picked up by add_rule.py.
let patterns: Vec<_> = include_str!("../resources/test/disallowed_rule_names.txt")
.trim()
.split('\n')
.map(|line| {
glob::Pattern::new(line).expect("malformed pattern in disallowed_rule_names.txt")
})
.collect();
for rule in Rule::iter() {
let rule_name = rule.as_ref();
for pattern in &patterns {
assert!(
!pattern.matches(rule_name),
"{rule_name} does not match naming convention, see CONTRIBUTING.md"
);
}
}
}
#[test] #[test]
fn check_code_serialization() { fn check_code_serialization() {
for rule in Rule::iter() { for rule in Rule::iter() {