Add checks to ensure the error_codes checker is "clean"
This commit is contained in:
parent
fbf1b1a719
commit
c755bbb36c
1 changed files with 13 additions and 3 deletions
|
@ -114,13 +114,18 @@ fn extract_error_codes(
|
||||||
.expect("failed to canonicalize error explanation file path");
|
.expect("failed to canonicalize error explanation file path");
|
||||||
match read_to_string(&path) {
|
match read_to_string(&path) {
|
||||||
Ok(content) => {
|
Ok(content) => {
|
||||||
if !IGNORE_EXPLANATION_CHECK.contains(&err_code.as_str())
|
let has_test = check_if_error_code_is_test_in_explanation(&content, &err_code);
|
||||||
&& !check_if_error_code_is_test_in_explanation(&content, &err_code)
|
if !has_test && !IGNORE_EXPLANATION_CHECK.contains(&err_code.as_str()) {
|
||||||
{
|
|
||||||
errors.push(format!(
|
errors.push(format!(
|
||||||
"`{}` doesn't use its own error code in compile_fail example",
|
"`{}` doesn't use its own error code in compile_fail example",
|
||||||
path.display(),
|
path.display(),
|
||||||
));
|
));
|
||||||
|
} else if has_test && IGNORE_EXPLANATION_CHECK.contains(&err_code.as_str()) {
|
||||||
|
errors.push(format!(
|
||||||
|
"`{}` has a compile_fail example with its own error code, it shouldn't \
|
||||||
|
be listed in IGNORE_EXPLANATION_CHECK!",
|
||||||
|
path.display(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if check_error_code_explanation(&content, error_codes, err_code) {
|
if check_error_code_explanation(&content, error_codes, err_code) {
|
||||||
errors.push(format!(
|
errors.push(format!(
|
||||||
|
@ -198,6 +203,11 @@ pub fn check(paths: &[&Path], bad: &mut bool) {
|
||||||
for (err_code, nb) in &error_codes {
|
for (err_code, nb) in &error_codes {
|
||||||
if !*nb && !EXEMPTED_FROM_TEST.contains(&err_code.as_str()) {
|
if !*nb && !EXEMPTED_FROM_TEST.contains(&err_code.as_str()) {
|
||||||
errors.push(format!("Error code {} needs to have at least one UI test!", err_code));
|
errors.push(format!("Error code {} needs to have at least one UI test!", err_code));
|
||||||
|
} else if *nb && EXEMPTED_FROM_TEST.contains(&err_code.as_str()) {
|
||||||
|
errors.push(format!(
|
||||||
|
"Error code {} has a UI test, it shouldn't be listed into EXEMPTED_FROM_TEST!",
|
||||||
|
err_code
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue