Skip to content

Commit 9addd3b

Browse files
committed
Added a tidy check to disallow "ignore" and "rust,ignore".
1 parent 2c89165 commit 9addd3b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/tools/tidy/src/style.rs

+15
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//! * No CR characters
1919
//! * No `TODO` or `XXX` directives
2020
//! * A valid license header is at the top
21+
//! * No unexplained ` ```ignore ` or ` ```rust,ignore ` doc tests
2122
//!
2223
//! A number of these checks can be opted-out of with various directives like
2324
//! `// ignore-tidy-linelength`.
@@ -38,6 +39,17 @@ http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3839
option. This file may not be copied, modified, or distributed
3940
except according to those terms.";
4041

42+
const UNEXPLAINED_IGNORE_DOCTEST_INFO: &str = r#"unexplained "```ignore" doctest; try one:
43+
44+
* make the test actually pass, by adding necessary imports and declarations, or
45+
* use "```text", if the code is not Rust code, or
46+
* use "```compile_fail,Ennnn", if the code is expected to fail at compile time, or
47+
* use "```should_panic", if the code is expected to fail at run time, or
48+
* use "```no_run", if the code should type-check but not necessary linkable/runnable, or
49+
* explain it like "```ignore (cannot-test-this-because-xxxx)", if the annotation cannot be avoided.
50+
51+
"#;
52+
4153
/// Parser states for line_is_url.
4254
#[derive(PartialEq)]
4355
#[allow(non_camel_case_types)]
@@ -138,6 +150,9 @@ pub fn check(path: &Path, bad: &mut bool) {
138150
err("XXX is deprecated; use FIXME")
139151
}
140152
}
153+
if line.ends_with("```ignore") || line.ends_with("```rust,ignore") {
154+
err(UNEXPLAINED_IGNORE_DOCTEST_INFO);
155+
}
141156
}
142157
if !licenseck(file, &contents) {
143158
tidy_error!(bad, "{}: incorrect license", file.display());

0 commit comments

Comments
 (0)