Skip to content

Commit

Permalink
fix summary of warning counted as warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Canop committed Feb 18, 2022
1 parent 85e4494 commit 8ba97b4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### next
- fix summary of warnings counted as warning

<a name="v2.0.0"></a>
### v2.0.0 - 2022/02/16
Major features:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bacon"
version = "2.0.0"
version = "2.0.1-dev"
authors = ["dystroy <[email protected]>"]
repository = "https://github.com/Canop/bacon"
description = "background rust compiler"
Expand Down
17 changes: 12 additions & 5 deletions src/line_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ impl From<&CommandOutputLine> for LineAnalysis {
(crate::CSI_BOLD_RED, r1, CSI_BOLD, _) if r1.starts_with("error") => {
LineType::Title(Kind::Error)
}
(crate::CSI_BOLD_YELLOW, "warning", _, r2)
if is_n_warnings_emitted(r2) =>
{
LineType::Title(Kind::Sum)
(crate::CSI_BOLD_YELLOW, "warning", _, r2) => {
if is_n_warnings_emitted(r2) {
LineType::Title(Kind::Sum)
} else if is_generated_n_warnings(content.strings.get(2)) {
LineType::Title(Kind::Sum)
} else {
LineType::Title(Kind::Warning)
}
}
(crate::CSI_BOLD_YELLOW, "warning", _, _) => LineType::Title(Kind::Warning),
("", r1, crate::CSI_BOLD_BLUE, "--> ") if is_spaces(r1) => {
LineType::Location
}
Expand All @@ -85,6 +88,10 @@ fn is_n_warnings_emitted(s: &str) -> bool {
regex_is_match!(r#"^: \d+ warnings? emitted"#, s)
}

fn is_generated_n_warnings(ts: Option<&TString>) -> bool {
ts.map_or(false, |ts| regex_is_match!(r#"generated \d+ warnings?$"#, &ts.raw))
}

/// return Some when the line is the non detailled
/// result of a test, for example
///
Expand Down

0 comments on commit 8ba97b4

Please sign in to comment.