From c4ac0f758d2a0176d331c1c95e089e58435070e1 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Wed, 1 Oct 2025 22:30:58 -0700 Subject: [PATCH 1/2] fix: parse clang-tidy output when `WarningsAsErrors` is asserted corresponds to cpp-linter/cpp-linter#162 --- cpp-linter/src/clang_tools/clang_tidy.rs | 16 ++++++++++------ cpp-linter/tests/demo/.clang-tidy | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cpp-linter/src/clang_tools/clang_tidy.rs b/cpp-linter/src/clang_tools/clang_tidy.rs index 0d364afc..81bfae0a 100644 --- a/cpp-linter/src/clang_tools/clang_tidy.rs +++ b/cpp-linter/src/clang_tools/clang_tidy.rs @@ -130,6 +130,9 @@ impl MakeSuggestions for TidyAdvice { } } +/// A regex pattern to capture the clang-tidy note header. +const NOTE_HEADER: &str = r"^(.+):(\d+):(\d+):\s(\w+):(.*)\[([a-zA-Z\d\-\.]+),?[^\]]*\]$"; + /// Parses clang-tidy stdout. /// /// Here it helps to have the JSON database deserialized for normalizing paths present @@ -138,7 +141,7 @@ fn parse_tidy_output( tidy_stdout: &[u8], database_json: &Option>, ) -> Result { - let note_header = Regex::new(r"^(.+):(\d+):(\d+):\s(\w+):(.*)\[([a-zA-Z\d\-\.]+)\]$").unwrap(); + let note_header = Regex::new(NOTE_HEADER).unwrap(); let fixed_note = Regex::new(r"^.+:(\d+):\d+:\snote: FIX-IT applied suggested code changes$").unwrap(); let mut found_fix = false; @@ -354,8 +357,7 @@ mod test { common_fs::FileObj, }; - use super::run_clang_tidy; - use super::TidyNotification; + use super::{run_clang_tidy, TidyNotification, NOTE_HEADER}; #[test] fn clang_diagnostic_link() { @@ -397,13 +399,15 @@ mod test { #[test] fn test_capture() { - let src = "tests/demo/demo.hpp:11:11: warning: use a trailing return type for this function [modernize-use-trailing-return-type]"; - let pat = Regex::new(r"^(.+):(\d+):(\d+):\s(\w+):(.*)\[([a-zA-Z\d\-\.]+)\]$").unwrap(); + let src = "tests/demo/demo.hpp:11:11: \ + warning: use a trailing return type for this function \ + [modernize-use-trailing-return-type,-warnings-as-errors]"; + let pat = Regex::new(NOTE_HEADER).unwrap(); let cap = pat.captures(src).unwrap(); assert_eq!( cap.get(0).unwrap().as_str(), format!( - "{}:{}:{}: {}:{}[{}]", + "{}:{}:{}: {}:{}[{},-warnings-as-errors]", cap.get(1).unwrap().as_str(), cap.get(2).unwrap().as_str(), cap.get(3).unwrap().as_str(), diff --git a/cpp-linter/tests/demo/.clang-tidy b/cpp-linter/tests/demo/.clang-tidy index d3865ade..ac9de51a 100644 --- a/cpp-linter/tests/demo/.clang-tidy +++ b/cpp-linter/tests/demo/.clang-tidy @@ -1,6 +1,6 @@ --- Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,performance-*,bugprone-*,clang-analyzer-*,mpi-*,misc-*,readability-*' -WarningsAsErrors: '' +WarningsAsErrors: '*' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false FormatStyle: 'file' From 6eee85afb2ce592d4ec6791056c43651da3112b2 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Wed, 1 Oct 2025 23:53:18 -0700 Subject: [PATCH 2/2] run all CI tests on windows runner --- .github/workflows/run-dev-tests.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/run-dev-tests.yml b/.github/workflows/run-dev-tests.yml index 9b16b63a..1623dd68 100644 --- a/.github/workflows/run-dev-tests.yml +++ b/.github/workflows/run-dev-tests.yml @@ -182,37 +182,31 @@ jobs: run: uvx nox -s test -- --profile ci - name: Install clang v19 - if: runner.os == 'Linux' uses: ./.github/install-clang-action with: version: '19' - name: Collect Coverage for clang v19 - if: runner.os == 'Linux' env: CLANG_VERSION: '19' run: uvx nox -s test -- --profile ci - name: Install clang v20 - if: runner.os == 'Linux' uses: ./.github/install-clang-action with: version: '20' - name: Collect Coverage for clang v20 - if: runner.os == 'Linux' env: CLANG_VERSION: '20' run: uvx nox -s test -- --profile ci - name: Install clang v21 - if: runner.os == 'Linux' uses: ./.github/install-clang-action with: version: '21' - name: Collect Coverage for clang v21 - if: runner.os == 'Linux' env: CLANG_VERSION: '21' run: uvx nox -s test -- --profile all