56 lines
1.5 KiB
Rust
Raw Normal View History

use walkdir::WalkDir;
2019-10-23 18:13:40 +03:00
use xtask::{
codegen::{self, Mode},
project_root, run_rustfmt,
};
#[test]
fn generated_grammar_is_fresh() {
2019-10-23 18:13:40 +03:00
if let Err(error) = codegen::generate_syntax(Mode::Verify) {
2019-10-17 23:01:53 +03:00
panic!("{}. Please update it by running `cargo xtask codegen`", error);
}
}
#[test]
fn generated_tests_are_fresh() {
2019-10-23 18:13:40 +03:00
if let Err(error) = codegen::generate_parser_tests(Mode::Verify) {
panic!("{}. Please update tests by running `cargo xtask codegen`", error);
}
}
2019-10-25 14:16:46 +03:00
#[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() {
2019-10-23 18:13:40 +03:00
if let Err(error) = run_rustfmt(Mode::Verify) {
2019-02-08 14:49:43 +03:00
panic!("{}. Please format the code by running `cargo format`", error);
}
}
2019-03-18 00:25:54 +03:00
#[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();
2019-12-25 18:33:56 +01:00
if text.contains("TODO") || text.contains("TOOD") || text.contains("todo!") {
2019-03-18 00:25:54 +03:00
panic!(
"\nTODO markers should not be committed to the master branch,\n\
2019-03-18 00:25:54 +03:00
use FIXME instead\n\
{}\n",
e.path().display(),
)
}
})
}