Skip to content

Commit

Permalink
Update regex for msbuild parser, add new test
Browse files Browse the repository at this point in the history
  • Loading branch information
pyatizbyantsevia authored and Пятизбянцев Илья Андреевич committed Oct 4, 2023
1 parent 590a415 commit cb7a590
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class MsBuildParser extends LookaheadParser {
+ ANT_TASK + "(?:(?:\\s*(?:\\d+|\\d+:\\d+)>)?(?:(?:(?:(.*?)\\((\\d*)(?:,(\\d+))?[a-zA-Z]*?\\)|.*LINK)\\s*:|"
+ "(.*):)\\s*([A-z-_]*\\s(?:[Nn]ote|[Ii]nfo|[Ww]arning|(?:fatal\\s*)?[Ee]rror))[^A-Za-z0-9]\\s*:?\\s*([A-Za-z0-9\\-_]+)?"
+ "\\s*:\\s(?:\\s*([A-Za-z0-9.]+)\\s*:)?\\s*(.*?)(?: \\[([^\\]]*)[/\\\\][^\\]\\\\]+\\])?"
+ "|(.*)\\s*:.*error\\s*(LNK[0-9]+):\\s*(.*)))$";
+ "|(.*)\\s*:.*(?:error|warning)\\s*(LNK[0-9]+):\\s*(.*)))$";

private final Pattern ignoredToolsPattern = Pattern.compile("(?!.exe)(\\.[^.]+)$");

Expand Down
37 changes: 32 additions & 5 deletions src/test/java/edu/hm/hafner/analysis/parser/MsBuildParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,19 @@ void issue10566() {
}

/**
* Parses a file with warnings of the MS Build tools.
* Parses a file with errors of the MS Build tools.
*
* @see <a href="https://issues.jenkins-ci.org/browse/JENKINS-3582">Issue 3582</a>
*/
@Test
void issue3582() {
Report warnings = parse("issue3582.txt");
Report errors = parse("issue3582.txt");

assertThat(warnings).hasSize(1);
assertThatReportHasSeverities(warnings, 1, 0, 0, 0);
assertThat(errors).hasSize(1);
assertThatReportHasSeverities(errors, 1, 0, 0, 0);

try (SoftAssertions softly = new SoftAssertions()) {
softly.assertThat(warnings.get(0))
softly.assertThat(errors.get(0))
.hasFileName("TestLib.lib")
.hasCategory("LNK1181")
.hasSeverity(Severity.ERROR)
Expand All @@ -456,6 +456,33 @@ void issue3582() {
}
}

/**
* Parses a file with warnings of the MS Build tools.
*
* @see <a href="https://issues.jenkins-ci.org/browse/JENKINS-63580">Issue 63580</a>
*/
@Test
void issue63580() {
Report warnings = parse("issue63580.txt");

assertThat(warnings).hasSize(1);
assertThatReportHasSeverities(warnings, 0, 0, 1, 0);

try (SoftAssertions softly = new SoftAssertions()) {
softly.assertThat(warnings.get(0))
.hasFileName("TestLib.lib")
.hasCategory("LNK4217")
.hasSeverity(Severity.WARNING_NORMAL)
.hasMessage("cannot open input file 'TestLib.lib'")
.hasDescription("")
.hasPackageName("-")
.hasLineStart(0)
.hasLineEnd(0)
.hasColumnStart(0)
.hasColumnEnd(0);
}
}

/**
* Parses a file with warnings of Stylecop.
*
Expand Down
11 changes: 11 additions & 0 deletions src/test/resources/edu/hm/hafner/analysis/parser/issue63580.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
...
[exec] 23>main.cpp
[exec] 23>Compiling resources...
[exec] 23>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
[exec] 23>Copyright (C) Microsoft Corporation. All rights reserved.
[exec] 23>Linking...
[exec] 23>LINK : warning LNK4217: symbol 'XYZ' defined in 'abc.obj' is imported by 'def.obj' in function 'FGH'
[exec] 23>Build log was saved at "..."
[exec] 23>MyApplication - 0 error(s), 1 warning(s)
[exec] ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

0 comments on commit cb7a590

Please sign in to comment.