Skip to content

Commit 1475a51

Browse files
committed
Rewrite .gitattributes CRLF ui tests into run-make tests
1 parent 42245d3 commit 1475a51

File tree

10 files changed

+108
-91
lines changed

10 files changed

+108
-91
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//@ reference: input.byte-order-mark
2+
//@ reference: input.crlf
3+
4+
use run_make_support::{rfs, rustc, tmp_dir};
5+
6+
fn main() {
7+
let aux_content = "\u{FEFF}\
8+
pub fn test() {\r\n\
9+
\r\n\
10+
let s : String = 1; // Error in the middle of line.\r\n\
11+
\r\n\
12+
let s : String = 1\r\n\
13+
; // Error before the newline.\r\n\
14+
\r\n\
15+
let s : String =\r\n\
16+
1; // Error after the newline.\r\n\
17+
\r\n\
18+
let s : String = (\r\n\
19+
); // Error spanning the newline.\r\n\
20+
}\r\n";
21+
22+
rfs::write(tmp_dir().join("json-bom-plus-crlf-multifile-aux.rs"), aux_content).unwrap();
23+
24+
let aux_bytes = rfs::read(tmp_dir().join("json-bom-plus-crlf-multifile-aux.rs")).unwrap();
25+
assert!(aux_bytes.starts_with(b"\xEF\xBB\xBF"), "File must start with UTF-8 BOM");
26+
assert!(aux_bytes.windows(2).any(|w| w == b"\r\n"), "File must contain CRLF line endings");
27+
28+
let main_content = "\u{FEFF}\
29+
#[path = \"json-bom-plus-crlf-multifile-aux.rs\"]\r\n\
30+
mod json_bom_plus_crlf_multifile_aux;\r\n\
31+
\r\n\
32+
fn main() {\r\n\
33+
json_bom_plus_crlf_multifile_aux::test();\r\n\
34+
}\r\n";
35+
36+
rfs::write(tmp_dir().join("json-bom-plus-crlf-multifile.rs"), main_content).unwrap();
37+
38+
let output = rustc()
39+
.input(tmp_dir().join("json-bom-plus-crlf-multifile.rs"))
40+
.json("diagnostic-short")
41+
.error_format("json")
42+
.run_fail()
43+
.stderr_utf8();
44+
45+
diff()
46+
.expected_file("json-bom-plus-crlf-multifile.stderr")
47+
.actual_text("stderr", &output)
48+
.run();
49+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//@ reference: input.byte-order-mark
2+
//@ reference: input.crlf
3+
4+
use run_make_support::{diff, rfs, rustc, tmp_dir};
5+
6+
fn main() {
7+
let main_content = "\u{FEFF}\
8+
fn main() {\r\n\
9+
\r\n\
10+
let s : String = 1; // Error in the middle of line.\r\n\
11+
\r\n\
12+
let s : String = 1\r\n\
13+
; // Error before the newline.\r\n\
14+
\r\n\
15+
let s : String =\r\n\
16+
1; // Error after the newline.\r\n\
17+
\r\n\
18+
let s : String = (\r\n\
19+
); // Error spanning the newline.\r\n\
20+
}\r\n";
21+
22+
let main_path = tmp_dir().join("json-bom-plus-crlf.rs");
23+
rfs::write(&main_path, main_content).unwrap();
24+
25+
let main_bytes = rfs::read(&main_path).unwrap();
26+
assert!(main_bytes.starts_with(b"\xEF\xBB\xBF"), "File must start with UTF-8 BOM");
27+
assert!(main_bytes.windows(2).any(|w| w == b"\r\n"), "File must contain CRLF line endings");
28+
29+
let output = rustc()
30+
.input(&main_path)
31+
.json("diagnostic-short")
32+
.error_format("json")
33+
.run_fail()
34+
.stderr_utf8();
35+
36+
diff().expected_file("json-bom-plus-crlf.stderr").actual_text("stderr", &output).run();
37+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use run_make_support::{diff, rfs, rustc, tmp_dir};
2+
3+
fn main() {
4+
let test_content = "fn main() {\n\
5+
// \\r\\n\n\
6+
let ok = \"This is \\\r\n\
7+
a test\";\n\
8+
// \\r only\n\
9+
let bad = \"This is \\\r\
10+
a test\";\n\
11+
}\n";
12+
13+
let test_path = tmp_dir().join("trailing-carriage-return-in-string.rs");
14+
rfs::write(&test_path, test_content).unwrap();
15+
16+
let output = rustc().input(&test_path).run_fail().stderr_utf8();
17+
18+
diff()
19+
.expected_file("trailing-carriage-return-in-string.stderr")
20+
.actual_text("stderr", &output)
21+
.run();
22+
}

tests/ui/json/json-bom-plus-crlf-multifile-aux.rs

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/ui/json/json-bom-plus-crlf-multifile.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/ui/json/json-bom-plus-crlf.rs

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/ui/parser/trailing-carriage-return-in-string.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)