tidy/
known_bug.rs

1//! Tidy check to ensure that tests inside 'tests/crashes' have a '@known-bug' directive.
2
3use std::path::Path;
4
5use crate::walk::*;
6
7pub fn check(filepath: &Path, bad: &mut bool) {
8    walk(filepath, |path, _is_dir| filter_not_rust(path), &mut |entry, contents| {
9        let file: &Path = entry.path();
10
11        // files in "auxiliary" do not need to crash by themselves
12        let test_path_segments =
13            file.iter().map(|s| s.to_string_lossy().into()).collect::<Vec<String>>();
14        let test_path_segments_str =
15            test_path_segments.iter().map(|s| s.as_str()).collect::<Vec<&str>>();
16
17        if !matches!(
18            test_path_segments_str[..],
19            [.., "tests", "crashes", "auxiliary", _aux_file_rs]
20        ) && !contents.lines().any(|line| line.starts_with("//@ known-bug: "))
21        {
22            tidy_error!(
23                bad,
24                "{} crash/ice test does not have a \"//@ known-bug: \" directive",
25                file.display()
26            );
27        }
28    });
29}