Added a tidy check to disallow "``ignore" and "``rust,ignore".

This commit is contained in:
kennytm 2017-06-21 01:00:02 +08:00
parent 2c89165814
commit 9addd3ba65
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C

View file

@ -18,6 +18,7 @@
//! * No CR characters
//! * No `TODO` or `XXX` directives
//! * A valid license header is at the top
//! * No unexplained ` ```ignore ` or ` ```rust,ignore ` doc tests
//!
//! A number of these checks can be opted-out of with various directives like
//! `// ignore-tidy-linelength`.
@ -38,6 +39,17 @@
option. This file may not be copied, modified, or distributed
except according to those terms.";
const UNEXPLAINED_IGNORE_DOCTEST_INFO: &str = r#"unexplained "```ignore" doctest; try one:
* make the test actually pass, by adding necessary imports and declarations, or
* use "```text", if the code is not Rust code, or
* use "```compile_fail,Ennnn", if the code is expected to fail at compile time, or
* use "```should_panic", if the code is expected to fail at run time, or
* use "```no_run", if the code should type-check but not necessary linkable/runnable, or
* explain it like "```ignore (cannot-test-this-because-xxxx)", if the annotation cannot be avoided.
"#;
/// Parser states for line_is_url.
#[derive(PartialEq)]
#[allow(non_camel_case_types)]
@ -138,6 +150,9 @@ pub fn check(path: &Path, bad: &mut bool) {
err("XXX is deprecated; use FIXME")
}
}
if line.ends_with("```ignore") || line.ends_with("```rust,ignore") {
err(UNEXPLAINED_IGNORE_DOCTEST_INFO);
}
}
if !licenseck(file, &contents) {
tidy_error!(bad, "{}: incorrect license", file.display());