rust/crates/ra_tools/tests/cli.rs

47 lines
1.2 KiB
Rust
Raw Normal View History

2019-03-17 16:25:54 -05:00
use walkdir::WalkDir;
use ra_tools::{gen_tests, generate, project_root, run_rustfmt, Verify};
#[test]
fn generated_grammar_is_fresh() {
2018-10-16 12:53:19 -05:00
if let Err(error) = generate(Verify) {
2018-10-16 13:09:22 -05:00
panic!("{}. Please update it by running `cargo gen-syntax`", error);
}
}
#[test]
fn generated_tests_are_fresh() {
if let Err(error) = gen_tests(Verify) {
2019-02-08 05:49:43 -06:00
panic!("{}. Please update tests by running `cargo gen-tests`", error);
}
}
#[test]
fn check_code_formatting() {
if let Err(error) = run_rustfmt(Verify) {
2019-02-08 05:49:43 -06:00
panic!("{}. Please format the code by running `cargo format`", error);
}
}
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();
if text.contains("TODO") {
panic!(
"\nTODO markers should not be commited to the master branch,\n\
use FIXME instead\n\
{}\n",
e.path().display(),
)
}
})
}