Skip to content

Commit 3c9ec96

Browse files
authored
Merge pull request rust-lang#3084 from otavio/issue-1990
Enable `stdin_disable_all_formatting_test` test
2 parents 4895699 + 2ae1b48 commit 3c9ec96

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

src/test/mod.rs

+27-22
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::io::{self, BufRead, BufReader, Read, Write};
1717
use std::iter::{Enumerate, Peekable};
1818
use std::mem;
1919
use std::path::{Path, PathBuf};
20+
use std::process::{Command, Stdio};
2021
use std::str::Chars;
2122

2223
use config::{Color, Config, EmitMode, FileName, ReportTactic};
@@ -287,28 +288,32 @@ fn stdin_formatting_smoke_test() {
287288
assert_eq!(buf, "fn main() {}\r\n".as_bytes());
288289
}
289290

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+
}
312317

313318
#[test]
314319
fn format_lines_errors_are_reported() {

0 commit comments

Comments
 (0)