From 0167c67ecb26df5c6cca53770779bdbffe22b81c Mon Sep 17 00:00:00 2001 From: Lorenz Aebi Date: Tue, 26 Feb 2019 20:56:56 +0100 Subject: [PATCH] [JENKINS-55750] Added test cases and fix warnings which could not been find --- .../hm/hafner/analysis/parser/IarParser.java | 4 +- .../hafner/analysis/parser/IarParserTest.java | 50 ++++++++++++++++++- .../hm/hafner/analysis/parser/issue55750.txt | 4 ++ 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 src/test/resources/edu/hm/hafner/analysis/parser/issue55750.txt diff --git a/src/main/java/edu/hm/hafner/analysis/parser/IarParser.java b/src/main/java/edu/hm/hafner/analysis/parser/IarParser.java index 0826d2ddc..01e18999c 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/IarParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/IarParser.java @@ -19,8 +19,8 @@ public class IarParser extends RegexpLineParser { private static final long serialVersionUID = 7695540852439013425L; - private static final String IAR_WARNING_PATTERN = ANT_TASK - + "(?:\"?(.*?)\"?[\\(,](\\d+)\\)?\\s+:?\\s+)?(Error|Remark|Warning|Fatal [Ee]rror)\\[(\\w+)\\]: (.*)$"; + private static final String IAR_WARNING_PATTERN = ANT_TASK + + "(?:\"?(.*?)\"?[\\(,](\\d+)\\)?\\s+(?::\\s)?)?(Error|Remark|Warning|Fatal [Ee]rror)\\[(\\w+)\\]: (.*)$"; /** * Creates a new instance of {@link IarParser}. diff --git a/src/test/java/edu/hm/hafner/analysis/parser/IarParserTest.java b/src/test/java/edu/hm/hafner/analysis/parser/IarParserTest.java index e1d3728d3..cc81425d7 100644 --- a/src/test/java/edu/hm/hafner/analysis/parser/IarParserTest.java +++ b/src/test/java/edu/hm/hafner/analysis/parser/IarParserTest.java @@ -1,11 +1,15 @@ package edu.hm.hafner.analysis.parser; +import org.junit.jupiter.api.Test; + import edu.hm.hafner.analysis.AbstractParserTest; import edu.hm.hafner.analysis.Report; import edu.hm.hafner.analysis.Severity; -import static edu.hm.hafner.analysis.assertj.IssuesAssert.*; import edu.hm.hafner.analysis.assertj.SoftAssertions; +import static edu.hm.hafner.analysis.assertj.Assertions.*; +import static edu.hm.hafner.analysis.assertj.SoftAssertions.*; + /** * Tests the class {@link IarParser}. * @@ -69,4 +73,46 @@ protected void assertThatIssuesArePresent(final Report report, final SoftAsserti .hasMessage("function \"FlashErase\" was declared but never referenced") .hasFileName("d:/jenkins/workspace/Nightly/src/flash/flashdrv.c"); } -} \ No newline at end of file + + /** + * Parses a warning log with IAR ARM warnings. + * + * @see Issue 55750 + */ + @Test + void issue55750() { + Report warnings = parse("issue55750.txt"); + assertThat(warnings).hasSize(4); + + assertSoftly(softly -> { + softly.assertThat(warnings.get(0)) + .hasSeverity(Severity.WARNING_NORMAL) + .hasCategory("Pe852") + .hasLineStart(432) + .hasLineEnd(432) + .hasMessage("expression must be a pointer to a complete object type") + .hasFileName("c:/external/specific/cpp/iar_cxxabi.cpp"); + softly.assertThat(warnings.get(1)) + .hasSeverity(Severity.WARNING_NORMAL) + .hasCategory("Pe549") + .hasLineStart(81) + .hasLineEnd(81) + .hasMessage("variable \"result\" is used before its value is set") + .hasFileName("external/specific/wiced/WICED/security/BESL/host/WICED/wiced_p2p.c"); + softly.assertThat(warnings.get(2)) + .hasSeverity(Severity.WARNING_NORMAL) + .hasCategory("Pe223") + .hasLineStart(412) + .hasLineEnd(412) + .hasMessage("function \"memcpy\" declared implicitly") + .hasFileName("external/specific/wiced/WICED/platform/MCU/RTOS_STM32F4xx/platform_dct_external.c"); + softly.assertThat(warnings.get(3)) + .hasSeverity(Severity.WARNING_HIGH) + .hasCategory("Pe018") + .hasLineStart(633) + .hasLineEnd(633) + .hasMessage("expected a \")\"") + .hasFileName("source/dal/InterMcu/InterMcuTransport.cpp"); + }); + } +} diff --git a/src/test/resources/edu/hm/hafner/analysis/parser/issue55750.txt b/src/test/resources/edu/hm/hafner/analysis/parser/issue55750.txt new file mode 100644 index 000000000..611a00a13 --- /dev/null +++ b/src/test/resources/edu/hm/hafner/analysis/parser/issue55750.txt @@ -0,0 +1,4 @@ +"c:\external\specific\cpp\iar_cxxabi.cpp",432 Warning[Pe852]: expression must be a pointer to a complete object type +"external/specific/wiced/WICED/security/BESL/host/WICED/wiced_p2p.c",81 Warning[Pe549]: variable "result" is used before its value is set +"external/specific/wiced/WICED/platform/MCU/RTOS_STM32F4xx/platform_dct_external.c",412 Warning[Pe223]: function "memcpy" declared implicitly +"source/dal/InterMcu/InterMcuTransport.cpp",633 Error[Pe018]: expected a ")"