@@ -17,6 +17,7 @@ use std::io::{self, BufRead, BufReader, Read, Write};
17
17
use std:: iter:: { Enumerate , Peekable } ;
18
18
use std:: mem;
19
19
use std:: path:: { Path , PathBuf } ;
20
+ use std:: process:: { Command , Stdio } ;
20
21
use std:: str:: Chars ;
21
22
22
23
use config:: { Color , Config , EmitMode , FileName , ReportTactic } ;
@@ -287,28 +288,32 @@ fn stdin_formatting_smoke_test() {
287
288
assert_eq ! ( buf, "fn main() {}\r \n " . as_bytes( ) ) ;
288
289
}
289
290
290
- // FIXME(#1990) restore this test
291
- // #[test]
292
- // fn stdin_disable_all_formatting_test() {
293
- // let input = String::from("fn main() { println!(\"This should not be formatted.\"); }");
294
- // let mut child = Command::new("./target/debug/rustfmt")
295
- // .stdin(Stdio::piped())
296
- // .stdout(Stdio::piped())
297
- // .arg("--config-path=./tests/config/disable_all_formatting.toml")
298
- // .spawn()
299
- // .expect("failed to execute child");
300
-
301
- // {
302
- // let stdin = child.stdin.as_mut().expect("failed to get stdin");
303
- // stdin
304
- // .write_all(input.as_bytes())
305
- // .expect("failed to write stdin");
306
- // }
307
- // let output = child.wait_with_output().expect("failed to wait on child");
308
- // assert!(output.status.success());
309
- // assert!(output.stderr.is_empty());
310
- // assert_eq!(input, String::from_utf8(output.stdout).unwrap());
311
- // }
291
+ #[ test]
292
+ fn stdin_disable_all_formatting_test ( ) {
293
+ match option_env ! ( "CFG_RELEASE_CHANNEL" ) {
294
+ None | Some ( "nightly" ) => { }
295
+ _ => return , // these tests require nightly
296
+ }
297
+ let input = String :: from ( "fn main() { println!(\" This should not be formatted.\" ); }" ) ;
298
+ let mut child = Command :: new ( "./target/debug/rustfmt" )
299
+ . stdin ( Stdio :: piped ( ) )
300
+ . stdout ( Stdio :: piped ( ) )
301
+ . arg ( "--config-path=./tests/config/disable_all_formatting.toml" )
302
+ . spawn ( )
303
+ . expect ( "failed to execute child" ) ;
304
+
305
+ {
306
+ let stdin = child. stdin . as_mut ( ) . expect ( "failed to get stdin" ) ;
307
+ stdin
308
+ . write_all ( input. as_bytes ( ) )
309
+ . expect ( "failed to write stdin" ) ;
310
+ }
311
+
312
+ let output = child. wait_with_output ( ) . expect ( "failed to wait on child" ) ;
313
+ assert ! ( output. status. success( ) ) ;
314
+ assert ! ( output. stderr. is_empty( ) ) ;
315
+ assert_eq ! ( input, String :: from_utf8( output. stdout) . unwrap( ) ) ;
316
+ }
312
317
313
318
#[ test]
314
319
fn format_lines_errors_are_reported ( ) {
0 commit comments