File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
rustfmt-core/rustfmt-bin/src/bin Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ struct Opt {
119119
120120 /// Error if unable to get comments or string literals within max_width,
121121 /// or they are left with trailing whitespaces (unstable).
122- #[ cfg_attr( nightly, structopt( long = "error_on_unformatted " ) ) ]
122+ #[ cfg_attr( nightly, structopt( long = "error-on-unformatted " ) ) ]
123123 #[ cfg_attr( not( nightly) , structopt( skip) ) ]
124124 error_on_unformatted : bool ,
125125
@@ -736,4 +736,30 @@ mod test {
736736 assert ! ( output. status. success( ) ) ;
737737 assert_eq ! ( std:: str :: from_utf8( & output. stdout) . unwrap( ) , "stdin\n " ) ;
738738 }
739+
740+ #[ cfg( nightly) ]
741+ #[ test]
742+ fn verify_error_on_unformatted ( ) {
743+ init_log ( ) ;
744+
745+ let mut child = Command :: new ( rustfmt ( ) )
746+ . arg ( "--error-on-unformatted" )
747+ . stdin ( Stdio :: piped ( ) )
748+ . stdout ( Stdio :: piped ( ) )
749+ . stderr ( Stdio :: piped ( ) )
750+ . spawn ( )
751+ . expect ( "run with check option failed" ) ;
752+
753+ {
754+ let stdin = child. stdin . as_mut ( ) . expect ( "Failed to open stdin" ) ;
755+ stdin
756+ . write_all ( b"fn main()\n {}\n " )
757+ . expect ( "Failed to write to rustfmt --check" ) ;
758+ }
759+
760+ let output = child
761+ . wait_with_output ( )
762+ . expect ( "Failed to wait on rustfmt child" ) ;
763+ assert ! ( output. status. success( ) ) ;
764+ }
739765}
You can’t perform that action at this time.
0 commit comments