Skip to content

Rewrite .gitattributes CRLF ui tests into run-make tests #142925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.

Erroneous code examples:

```compile_fail,E0308
fn plus_one(x: i32) -> i32 {
x + 1
}

plus_one(\"Not a number\");
// ^^^^^^^^^^^^^^ expected `i32`, found `&str`

if \"Not a bool\" {
// ^^^^^^^^^^^^ expected `bool`, found `&str`
}

let x: f32 = \"Not a float\";
// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
// |
// expected due to this
```

This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC: error[E0308]: mismatched types: expected `String`, found integer
"}
{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.

Erroneous code examples:

```compile_fail,E0308
fn plus_one(x: i32) -> i32 {
x + 1
}

plus_one(\"Not a number\");
// ^^^^^^^^^^^^^^ expected `i32`, found `&str`

if \"Not a bool\" {
// ^^^^^^^^^^^^ expected `bool`, found `&str`
}

let x: f32 = \"Not a float\";
// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
// |
// expected due to this
```

This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC: error[E0308]: mismatched types: expected `String`, found integer
"}
{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.

Erroneous code examples:

```compile_fail,E0308
fn plus_one(x: i32) -> i32 {
x + 1
}

plus_one(\"Not a number\");
// ^^^^^^^^^^^^^^ expected `i32`, found `&str`

if \"Not a bool\" {
// ^^^^^^^^^^^^ expected `bool`, found `&str`
}

let x: f32 = \"Not a float\";
// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
// |
// expected due to this
```

This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String =","highlight_start":XX,"highlight_end":XX}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC: error[E0308]: mismatched types: expected `String`, found integer
"}
{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.

Erroneous code examples:

```compile_fail,E0308
fn plus_one(x: i32) -> i32 {
x + 1
}

plus_one(\"Not a number\");
// ^^^^^^^^^^^^^^ expected `i32`, found `&str`

if \"Not a bool\" {
// ^^^^^^^^^^^^ expected `bool`, found `&str`
}

let x: f32 = \"Not a float\";
// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
// |
// expected due to this
```

This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = (","highlight_start":XX,"highlight_end":XX},{"text":"); // Error spanning the newline.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf-multifile-aux.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = (","highlight_start":XX,"highlight_end":XX}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC: error[E0308]: mismatched types: expected `String`, found `()`
"}
{"$message_type":"diagnostic","message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors
"}
72 changes: 72 additions & 0 deletions tests/run-make/json-bom-plus-crlf-multifile/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//@ reference: input.byte-order-mark
//@ reference: input.crlf

use run_make_support::{cwd, diff, rfs, rustc};

fn main() {
let aux_content = "\u{FEFF}\
pub fn test() {\r\n\
\r\n\
let s : String = 1; // Error in the middle of line.\r\n\
\r\n\
let s : String = 1\r\n\
; // Error before the newline.\r\n\
\r\n\
let s : String =\r\n\
1; // Error after the newline.\r\n\
\r\n\
let s : String = (\r\n\
); // Error spanning the newline.\r\n\
}\r\n";

rfs::write(cwd().join("json-bom-plus-crlf-multifile-aux.rs"), aux_content);

let aux_bytes = rfs::read(cwd().join("json-bom-plus-crlf-multifile-aux.rs"));
assert!(aux_bytes.starts_with(b"\xEF\xBB\xBF"), "File must start with UTF-8 BOM");
assert!(aux_bytes.windows(2).any(|w| w == b"\r\n"), "File must contain CRLF line endings");

let main_content = "\u{FEFF}\
#[path = \"json-bom-plus-crlf-multifile-aux.rs\"]\r\n\
mod json_bom_plus_crlf_multifile_aux;\r\n\
\r\n\
fn main() {\r\n\
json_bom_plus_crlf_multifile_aux::test();\r\n\
}\r\n";

rfs::write(cwd().join("json-bom-plus-crlf-multifile.rs"), main_content);

let output = rustc()
.input(cwd().join("json-bom-plus-crlf-multifile.rs"))
.json("diagnostic-short")
.error_format("json")
.ui_testing()
.run_fail()
.stderr_utf8();

diff()
.expected_file("json-bom-plus-crlf-multifile.stderr")
.actual_text("stderr", &output)
.normalize(r"\\n", "\n")
.normalize(r"\\r\\n", "\n")
.normalize(r#""line_start":\d+"#, r#""line_start":LL"#)
.normalize(r#""line_end":\d+"#, r#""line_end":LL"#)
.normalize(r#""column_start":\d+"#, r#""column_start":CC"#)
.normalize(r#""column_end":\d+"#, r#""column_end":CC"#)
.normalize(r#""byte_start":\d+"#, r#""byte_start":XXX"#)
.normalize(r#""byte_end":\d+"#, r#""byte_end":XXX"#)
.normalize(r#""highlight_start":\d+"#, r#""highlight_start":XX"#)
.normalize(r#""highlight_end":\d+"#, r#""highlight_end":XX"#)
.normalize(
r#""file_name":"[^"]*json-bom-plus-crlf-multifile-aux\.rs""#,
r#""file_name":"$$DIR/json-bom-plus-crlf-multifile-aux.rs""#,
)
.normalize(
r#""rendered":"(?:[^"]*/)?json-bom-plus-crlf-multifile-aux\.rs:\d+:\d+:"#,
r#""rendered":"$$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC:"#,
)
.normalize(
r#""rendered":"(?:[^"]*/)?json-bom-plus-crlf-multifile-aux\.rs:\d+:\d+ error"#,
r#""rendered":"$$DIR/json-bom-plus-crlf-multifile-aux.rs:LL:CC error"#,
)
.run();
}
114 changes: 114 additions & 0 deletions tests/run-make/json-bom-plus-crlf/json-bom-plus-crlf.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.

Erroneous code examples:

```compile_fail,E0308
fn plus_one(x: i32) -> i32 {
x + 1
}

plus_one(\"Not a number\");
// ^^^^^^^^^^^^^^ expected `i32`, found `&str`

if \"Not a bool\" {
// ^^^^^^^^^^^^ expected `bool`, found `&str`
}

let x: f32 = \"Not a float\";
// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
// |
// expected due to this
```

This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1; // Error in the middle of line.","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:LL:CC: error[E0308]: mismatched types: expected `String`, found integer
"}
{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.

Erroneous code examples:

```compile_fail,E0308
fn plus_one(x: i32) -> i32 {
x + 1
}

plus_one(\"Not a number\");
// ^^^^^^^^^^^^^^ expected `i32`, found `&str`

if \"Not a bool\" {
// ^^^^^^^^^^^^ expected `bool`, found `&str`
}

let x: f32 = \"Not a float\";
// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
// |
// expected due to this
```

This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = 1","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:LL:CC: error[E0308]: mismatched types: expected `String`, found integer
"}
{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.

Erroneous code examples:

```compile_fail,E0308
fn plus_one(x: i32) -> i32 {
x + 1
}

plus_one(\"Not a number\");
// ^^^^^^^^^^^^^^ expected `i32`, found `&str`

if \"Not a bool\" {
// ^^^^^^^^^^^^ expected `bool`, found `&str`
}

let x: f32 = \"Not a float\";
// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
// |
// expected due to this
```

This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found integer","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String =","highlight_start":XX,"highlight_end":XX}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"try using a conversion method","code":null,"level":"help","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"1; // Error after the newline.","highlight_start":XX,"highlight_end":XX}],"label":null,"suggested_replacement":".to_string()","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"$DIR/json-bom-plus-crlf.rs:LL:CC: error[E0308]: mismatched types: expected `String`, found integer
"}
{"$message_type":"diagnostic","message":"mismatched types","code":{"code":"E0308","explanation":"Expected type did not match the received type.

Erroneous code examples:

```compile_fail,E0308
fn plus_one(x: i32) -> i32 {
x + 1
}

plus_one(\"Not a number\");
// ^^^^^^^^^^^^^^ expected `i32`, found `&str`

if \"Not a bool\" {
// ^^^^^^^^^^^^ expected `bool`, found `&str`
}

let x: f32 = \"Not a float\";
// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
// |
// expected due to this
```

This error occurs when an expression was used in a place where the compiler
expected an expression of a different type. It can occur in several cases, the
most common being when calling a function and passing an argument which has a
different type than the matching type in the function declaration.
"},"level":"error","spans":[{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":true,"text":[{"text":"let s : String = (","highlight_start":XX,"highlight_end":XX},{"text":"); // Error spanning the newline.","highlight_start":XX,"highlight_end":XX}],"label":"expected `String`, found `()`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/json-bom-plus-crlf.rs","byte_start":XXX,"byte_end":XXX,"line_start":LL,"line_end":LL,"column_start":CC,"column_end":CC,"is_primary":false,"text":[{"text":"let s : String = (","highlight_start":XX,"highlight_end":XX}],"label":"expected due to this","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"$DIR/json-bom-plus-crlf.rs:LL:CC: error[E0308]: mismatched types: expected `String`, found `()`
"}
{"$message_type":"diagnostic","message":"aborting due to 4 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 4 previous errors
"}
Loading
Loading