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