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:
Sebastian Blunt 2017-02-19 19:57:02 +01:00
parent f6ccbd71c3
commit 235f33b230
No known key found for this signature in database
GPG Key ID: 5AD353DE058346B1
25 changed files with 34 additions and 6 deletions

View File

@ -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,

View File

@ -1,4 +1,5 @@
// rustfmt-wrap_comments: true
// rustfmt-error_on_line_overflow: false
// Enums test
#[atrr]

View File

@ -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 {

View File

@ -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;

View File

@ -1,4 +1,5 @@
// rustfmt-normalize_comments: true
// rustfmt-error_on_line_overflow: false
// Imports.

View File

@ -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();
}

View File

@ -1,4 +1,5 @@
// rustfmt-force_format_strings: true
// rustfmt-error_on_line_overflow: false
// Long string literals
fn main() -> &'static str {

View File

@ -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");

View File

@ -1,5 +1,6 @@
// rustfmt-normalize_comments: true
// rustfmt-wrap_comments: true
// rustfmt-error_on_line_overflow: false
// Struct literal expressions.
fn main() {

View File

@ -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.

View File

@ -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.

View File

@ -1,5 +1,6 @@
// rustfmt-normalize_comments: true
// rustfmt-wrap_comments: true
// rustfmt-error_on_line_overflow: false
/// A Doc comment
#[AnAttribute]

View File

@ -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);

View File

@ -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,

View File

@ -1,4 +1,5 @@
// rustfmt-wrap_comments: true
// rustfmt-error_on_line_overflow: false
// Enums test
#[atrr]

View File

@ -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 {

View File

@ -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;

View File

@ -1,4 +1,5 @@
// rustfmt-normalize_comments: true
// rustfmt-error_on_line_overflow: false
// Imports.

View File

@ -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();
}

View File

@ -1,4 +1,5 @@
// rustfmt-force_format_strings: true
// rustfmt-error_on_line_overflow: false
// Long string literals
fn main() -> &'static str {

View File

@ -1,4 +1,5 @@
// rustfmt-format_strings: true
// rustfmt-error_on_line_overflow: false
fn main() {
println!("ThisIsAReallyLongStringWithNoSpaces.It_should_prefer_to_break_onpunctuation:\

View File

@ -1,5 +1,6 @@
// rustfmt-normalize_comments: true
// rustfmt-wrap_comments: true
// rustfmt-error_on_line_overflow: false
// Struct literal expressions.
fn main() {

View File

@ -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.

View File

@ -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.

View File

@ -1,5 +1,6 @@
// rustfmt-normalize_comments: true
// rustfmt-wrap_comments: true
// rustfmt-error_on_line_overflow: false
/// A Doc comment
#[AnAttribute]