forgot something & add test macros

also added two small test to see that it works
This commit is contained in:
Johann150
2020-07-15 20:07:32 +02:00
parent 12ab4dfce5
commit e67efa01da
4 changed files with 63 additions and 2 deletions
+5 -2
View File
@@ -419,7 +419,7 @@ where
/// Output a short diagnostic, with a line number, severity, and message.
pub struct ShortDiagnostic<'diagnostic, FileId> {
diagnostic: &'diagnostic Diagnostic<FileId>,
show_notes: bool
show_notes: bool,
}
impl<'diagnostic, FileId> ShortDiagnostic<'diagnostic, FileId>
@@ -430,7 +430,10 @@ where
diagnostic: &'diagnostic Diagnostic<FileId>,
show_notes: bool,
) -> ShortDiagnostic<'diagnostic, FileId> {
ShortDiagnostic { diagnostic, show_notes }
ShortDiagnostic {
diagnostic,
show_notes,
}
}
pub fn render<'files>(
@@ -0,0 +1,17 @@
---
source: codespan-reporting/tests/term.rs
expression: TEST_DATA.emit_color(&config)
---
{fg:Red bold bright}bug{bold bright}: {/}
{fg:Red bold bright}error{bold bright}: {/}
{fg:Yellow bold bright}warning{bold bright}: {/}
{fg:Green bold bright}note{bold bright}: {/}
{fg:Cyan bold bright}help{bold bright}: {/}
{fg:Red bold bright}bug{bold bright}: {/}
@@ -0,0 +1,17 @@
---
source: codespan-reporting/tests/term.rs
expression: TEST_DATA.emit_no_color(&config)
---
bug:
error:
warning:
note:
help:
bug:
+24
View File
@@ -26,6 +26,17 @@ macro_rules! test_emit {
insta::assert_snapshot!(TEST_DATA.emit_color(&config));
}
};
(medium_color) => {
#[test]
fn medium_color() {
let config = Config {
display_style: DisplayStyle::Medium,
..TEST_CONFIG.clone()
};
insta::assert_snapshot!(TEST_DATA.emit_color(&config));
}
};
(short_color) => {
#[test]
fn short_color() {
@@ -48,6 +59,17 @@ macro_rules! test_emit {
insta::assert_snapshot!(TEST_DATA.emit_no_color(&config));
}
};
(medium_no_color) => {
#[test]
fn medium_no_color() {
let config = Config {
display_style: DisplayStyle::Medium,
..TEST_CONFIG.clone()
};
insta::assert_snapshot!(TEST_DATA.emit_no_color(&config));
}
};
(short_no_color) => {
#[test]
fn short_no_color() {
@@ -82,8 +104,10 @@ mod empty {
}
test_emit!(rich_color);
test_emit!(medium_color);
test_emit!(short_color);
test_emit!(rich_no_color);
test_emit!(medium_no_color);
test_emit!(short_no_color);
}