add errorcode tests

This commit is contained in:
Johann150 2020-09-06 21:45:38 +02:00
parent b72f4c5ab0
commit 5acc81e717
3 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,21 @@
---
source: codespan-reporting/tests/term.rs
expression: TEST_DATA.emit_no_color(&config)
---
error[E0001]: a message
warning[W001]: a message
note[N0815]: a message
help[H4711]: a message
error: where did my errorcode go?
warning: where did my errorcode go?
note: where did my errorcode go?
help: where did my errorcode go?

View File

@ -0,0 +1,13 @@
---
source: codespan-reporting/tests/term.rs
expression: TEST_DATA.emit_no_color(&config)
---
error[E0001]: a message
warning[W001]: a message
note[N0815]: a message
help[H4711]: a message
error: where did my errorcode go?
warning: where did my errorcode go?
note: where did my errorcode go?
help: where did my errorcode go?

View File

@ -325,6 +325,32 @@ mod message_and_notes {
test_emit!(short_no_color);
}
mod message_errorcode {
use super::*;
lazy_static::lazy_static! {
static ref TEST_DATA: TestData<'static, SimpleFiles<&'static str, &'static str>> = {
let files = SimpleFiles::new();
let diagnostics = vec![
Diagnostic::error().with_message("a message").with_code("E0001"),
Diagnostic::warning().with_message("a message").with_code("W001"),
Diagnostic::note().with_message("a message").with_code("N0815"),
Diagnostic::help().with_message("a message").with_code("H4711"),
Diagnostic::error().with_message("where did my errorcode go?").with_code(""),
Diagnostic::warning().with_message("where did my errorcode go?").with_code(""),
Diagnostic::note().with_message("where did my errorcode go?").with_code(""),
Diagnostic::help().with_message("where did my errorcode go?").with_code(""),
];
TestData { files, diagnostics }
};
}
test_emit!(rich_no_color);
test_emit!(short_no_color);
}
mod empty_ranges {
use super::*;