Skip to content

Commit 75a36f2

Browse files
committed
Add a test for 'disable_all_formatting = true' with stdin
1 parent ede179c commit 75a36f2

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
disable_all_formatting = true

tests/system.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ extern crate term;
1414

1515
use std::collections::HashMap;
1616
use std::fs;
17-
use std::io::{self, BufRead, BufReader, Read};
17+
use std::io::{self, BufRead, BufReader, Read, Write};
1818
use std::path::{Path, PathBuf};
19+
use std::process::{Command, Stdio};
1920

2021
use rustfmt::*;
2122
use rustfmt::filemap::{write_system_newlines, FileMap};
@@ -157,6 +158,28 @@ fn stdin_formatting_smoke_test() {
157158
panic!("no stdin");
158159
}
159160

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+
160183
#[test]
161184
fn format_lines_errors_are_reported() {
162185
let long_identifier = String::from_utf8(vec![b'a'; 239]).unwrap();

0 commit comments

Comments
 (0)