aboutsummaryrefslogtreecommitdiff
path: root/xtask/tests/tidy-tests/cli.rs
blob: 573ffadbf8eec9e68da691d6bea7e76bb6105eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use walkdir::WalkDir;
use xtask::{
    codegen::{self, Mode},
    project_root, run_rustfmt,
};

#[test]
fn generated_grammar_is_fresh() {
    if let Err(error) = codegen::generate_syntax(Mode::Verify) {
        panic!("{}. Please update it by running `cargo xtask codegen`", error);
    }
}

#[test]
fn generated_tests_are_fresh() {
    if let Err(error) = codegen::generate_parser_tests(Mode::Verify) {
        panic!("{}. Please update tests by running `cargo xtask codegen`", error);
    }
}

#[test]
fn generated_assists_are_fresh() {
    if let Err(error) = codegen::generate_assists_docs(Mode::Verify) {
        panic!("{}. Please update assists by running `cargo xtask codegen`", error);
    }
}

#[test]
fn check_code_formatting() {
    if let Err(error) = run_rustfmt(Mode::Verify) {
        panic!("{}. Please format the code by running `cargo format`", error);
    }
}

#[test]
fn no_todo() {
    WalkDir::new(project_root().join("crates")).into_iter().for_each(|e| {
        let e = e.unwrap();
        if e.path().extension().map(|it| it != "rs").unwrap_or(true) {
            return;
        }
        if e.path().ends_with("tests/cli.rs") {
            return;
        }
        let text = std::fs::read_to_string(e.path()).unwrap();
        if text.contains("TODO") || text.contains("TOOD") {
            panic!(
                "\nTODO markers should not be committed to the master branch,\n\
                 use FIXME instead\n\
                 {}\n",
                e.path().display(),
            )
        }
    })
}