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