Make tests fail if rustfmt encounters an error
Previously tests would not fail if they encountered an error such as LineOverflow or TrailingWhitespace. Making the tests error out will fix this mismatch between running rustfmt for real and running the tests. This also modifies all tests that previously contained errors so that they no longer contain errors (in almost all of the tests this is accomplished by setting error_on_line_overflow = false).
This commit is contained in:
parent
f6ccbd71c3
commit
235f33b230
@ -18,7 +18,7 @@ fn test() {
|
||||
* amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis
|
||||
* felis, pulvinar a semper sed, adipiscing id dolor. */
|
||||
|
||||
// Very looooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment that should be split
|
||||
// Very loooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment that should be split
|
||||
|
||||
// println!("{:?}", rewrite_comment(subslice,
|
||||
// false,
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Enums test
|
||||
|
||||
#[atrr]
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-file_lines: [{"file":"tests/source/file-lines-3.rs","range":[4,8]},{"file":"tests/source/file-lines-3.rs","range":[10,15]}]
|
||||
// rustfmt-file_lines: [{"file":"tests/source/file-lines-3.rs","range":[5,9]},{"file":"tests/source/file-lines-3.rs","range":[11,16]}]
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn floaters() {
|
||||
let x = Foo {
|
||||
|
@ -2,6 +2,7 @@
|
||||
// rustfmt-single_line_if_else_max_width: 0
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-hard_tabs: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn main() {
|
||||
let x = Bar;
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Imports.
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
mod client {
|
||||
impl Client {
|
||||
fn test(self) -> Result<()> {
|
||||
@ -10,7 +12,7 @@ mod client {
|
||||
let next_state = match self.state {
|
||||
State::V5(v5::State::Command(v5::comand::State::WriteVersion(ref mut response))) => {
|
||||
// The pattern cannot be formatted in a way that the match stays
|
||||
// within the column limit. The rewrite should therefore be
|
||||
// within the column limit. The rewrite should therefore be
|
||||
// skipped.
|
||||
let x = dont . reformat . meeee();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-force_format_strings: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Long string literals
|
||||
|
||||
fn main() -> &'static str {
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-format_strings: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn main() {
|
||||
println!("ThisIsAReallyLongStringWithNoSpaces.It_should_prefer_to_break_onpunctuation:Likethisssssssssssss");
|
||||
|
@ -1,5 +1,6 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Struct literal expressions.
|
||||
|
||||
fn main() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Struct literal expressions.
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
// rustfmt-struct_lit_multiline_style: ForceMulti
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Struct literal expressions.
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
/// A Doc comment
|
||||
#[AnAttribute]
|
||||
|
@ -179,6 +179,10 @@ fn check_files<I>(files: I) -> (Vec<FormatReport>, u32, u32)
|
||||
println!("Testing '{}'...", file_name);
|
||||
|
||||
match idempotent_check(file_name) {
|
||||
Ok(ref report) if report.has_warnings() => {
|
||||
print!("{}", report);
|
||||
fails += 1;
|
||||
}
|
||||
Ok(report) => reports.push(report),
|
||||
Err(msg) => {
|
||||
print_mismatches(msg);
|
||||
|
@ -18,7 +18,7 @@ fn test() {
|
||||
* amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis
|
||||
* felis, pulvinar a semper sed, adipiscing id dolor. */
|
||||
|
||||
// Very looooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment that should be split
|
||||
// Very loooooooooooooooooooooooooooooooooooooooooooooooooooooooong comment that should be split
|
||||
|
||||
// println!("{:?}", rewrite_comment(subslice,
|
||||
// false,
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Enums test
|
||||
|
||||
#[atrr]
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-file_lines: [{"file":"tests/source/file-lines-3.rs","range":[4,8]},{"file":"tests/source/file-lines-3.rs","range":[10,15]}]
|
||||
// rustfmt-file_lines: [{"file":"tests/source/file-lines-3.rs","range":[5,9]},{"file":"tests/source/file-lines-3.rs","range":[11,16]}]
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn floaters() {
|
||||
let x = Foo {
|
||||
|
@ -2,6 +2,7 @@
|
||||
// rustfmt-single_line_if_else_max_width: 0
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-hard_tabs: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn main() {
|
||||
let x = Bar;
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Imports.
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
mod client {
|
||||
impl Client {
|
||||
fn test(self) -> Result<()> {
|
||||
@ -10,7 +12,7 @@ mod client {
|
||||
let next_state = match self.state {
|
||||
State::V5(v5::State::Command(v5::comand::State::WriteVersion(ref mut response))) => {
|
||||
// The pattern cannot be formatted in a way that the match stays
|
||||
// within the column limit. The rewrite should therefore be
|
||||
// within the column limit. The rewrite should therefore be
|
||||
// skipped.
|
||||
let x = dont . reformat . meeee();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-force_format_strings: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Long string literals
|
||||
|
||||
fn main() -> &'static str {
|
||||
|
@ -1,4 +1,5 @@
|
||||
// rustfmt-format_strings: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
fn main() {
|
||||
println!("ThisIsAReallyLongStringWithNoSpaces.It_should_prefer_to_break_onpunctuation:\
|
||||
|
@ -1,5 +1,6 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
// Struct literal expressions.
|
||||
|
||||
fn main() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Struct literal expressions.
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
// rustfmt-struct_lit_multiline_style: ForceMulti
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
// Struct literal expressions.
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-error_on_line_overflow: false
|
||||
|
||||
/// A Doc comment
|
||||
#[AnAttribute]
|
||||
|
Loading…
x
Reference in New Issue
Block a user