@@ -14,8 +14,9 @@ extern crate term;
14
14
15
15
use std:: collections:: HashMap ;
16
16
use std:: fs;
17
- use std:: io:: { self , BufRead , BufReader , Read } ;
17
+ use std:: io:: { self , BufRead , BufReader , Read , Write } ;
18
18
use std:: path:: { Path , PathBuf } ;
19
+ use std:: process:: { Command , Stdio } ;
19
20
20
21
use rustfmt:: * ;
21
22
use rustfmt:: filemap:: { write_system_newlines, FileMap } ;
@@ -157,6 +158,28 @@ fn stdin_formatting_smoke_test() {
157
158
panic ! ( "no stdin" ) ;
158
159
}
159
160
161
+ #[ test]
162
+ fn stdin_disable_all_formatting_test ( ) {
163
+ let input = String :: from ( "fn main() { println!(\" This should not be formatted.\" ); }" ) ;
164
+ let mut child = Command :: new ( "./target/debug/rustfmt" )
165
+ . stdin ( Stdio :: piped ( ) )
166
+ . stdout ( Stdio :: piped ( ) )
167
+ . arg ( "--config-path=./tests/config/disable_all_formatting.toml" )
168
+ . spawn ( )
169
+ . expect ( "failed to execute child" ) ;
170
+
171
+ {
172
+ let stdin = child. stdin . as_mut ( ) . expect ( "failed to get stdin" ) ;
173
+ stdin
174
+ . write_all ( input. as_bytes ( ) )
175
+ . expect ( "failed to write stdin" ) ;
176
+ }
177
+ let output = child. wait_with_output ( ) . expect ( "failed to wait on child" ) ;
178
+ assert ! ( output. status. success( ) ) ;
179
+ assert ! ( output. stderr. is_empty( ) ) ;
180
+ assert_eq ! ( input, String :: from_utf8( output. stdout) . unwrap( ) ) ;
181
+ }
182
+
160
183
#[ test]
161
184
fn format_lines_errors_are_reported ( ) {
162
185
let long_identifier = String :: from_utf8 ( vec ! [ b'a' ; 239 ] ) . unwrap ( ) ;
0 commit comments