Skip to content

Commit cd23c85

Browse files
committed
normalize newlines
1 parent 63a8a05 commit cd23c85

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tests/rustfmt/main.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ mod rustfmt_stdin_formatting {
198198
#[rustfmt::skip]
199199
#[test]
200200
fn changes_are_output_to_stdout() {
201-
let args = [];
201+
// line endings are normalized to '\n' to avoid platform differences
202+
let args = ["--config", "newline_style=Unix"];
202203
let source = "fn main () { println!(\"hello world!\"); }";
203204
let (stdout, _stderr) = rustfmt_std_input(&args, source);
204205
let expected_output =
@@ -242,11 +243,14 @@ r#"fn main() {
242243
#[test]
243244
fn input_formatted_when_stdin_file_hint_is_not_ignored() {
244245
// NOTE: `src/bin/main.rs` is not ignored in the config file so the input is formatted.
246+
// line endings are normalized to '\n' to avoid platform differences
245247
let args = [
246248
"--stdin-file-hint",
247249
"src/bin/main.rs",
248250
"--config-path",
249251
"tests/config/stdin-file-hint-ignore.toml",
252+
"--config",
253+
"newline_style=Unix",
250254
];
251255
let source = "fn main () { println!(\"hello world!\"); }";
252256
let (stdout, _stderr) = rustfmt_std_input(&args, source);
@@ -267,11 +271,14 @@ r#"fn main() {
267271
fn ignore_list_is_not_set_on_stable_channel_and_therefore_stdin_file_hint_does_nothing() {
268272
// NOTE: the source is not properly formatted, and although the file is `ignored` we
269273
// can't set the `ignore` list on the stable channel so the input is formatted
274+
// line endings are normalized to '\n' to avoid platform differences
270275
let args = [
271276
"--stdin-file-hint",
272277
"src/lib.rs",
273278
"--config-path",
274279
"tests/config/stdin-file-hint-ignore.toml",
280+
"--config",
281+
"newline_style=Unix",
275282
];
276283
let source = "fn main () { println!(\"hello world!\"); }";
277284
let (stdout, _stderr) = rustfmt_std_input(&args, source);

0 commit comments

Comments
 (0)