Skip to content

Commit

Permalink
Fix typo: error-on-unformatted (#4011)
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro authored Jan 14, 2020
1 parent cc56957 commit 70ce551
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion rustfmt-core/rustfmt-bin/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct Opt {

/// Error if unable to get comments or string literals within max_width,
/// or they are left with trailing whitespaces (unstable).
#[cfg_attr(nightly, structopt(long = "error_on_unformatted"))]
#[cfg_attr(nightly, structopt(long = "error-on-unformatted"))]
#[cfg_attr(not(nightly), structopt(skip))]
error_on_unformatted: bool,

Expand Down Expand Up @@ -736,4 +736,30 @@ mod test {
assert!(output.status.success());
assert_eq!(std::str::from_utf8(&output.stdout).unwrap(), "stdin\n");
}

#[cfg(nightly)]
#[test]
fn verify_error_on_unformatted() {
init_log();

let mut child = Command::new(rustfmt())
.arg("--error-on-unformatted")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.expect("run with check option failed");

{
let stdin = child.stdin.as_mut().expect("Failed to open stdin");
stdin
.write_all(b"fn main()\n{}\n")
.expect("Failed to write to rustfmt --check");
}

let output = child
.wait_with_output()
.expect("Failed to wait on rustfmt child");
assert!(output.status.success());
}
}

0 comments on commit 70ce551

Please sign in to comment.