Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[FIXED JENKINS-11799] improve warning category for gcc 4.6 or later.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnou committed Jan 13, 2013
1 parent 04da997 commit b137e72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Expand Up @@ -16,6 +16,7 @@ public class Gcc4CompilerParser extends RegexpLineParser {
private static final long serialVersionUID = 5490211629355204910L;
private static final String ERROR = "error";
private static final String GCC_WARNING_PATTERN = ANT_TASK + "(.+?):(\\d+):(?:\\d+:)? (warning|error): (.*)$";
private static final Pattern CLASS_PATTERN = Pattern.compile("\\[-W(.+)\\]$");

/**
* Creates a new instance of <code>Gcc4CompilerParser</code>.
Expand All @@ -39,23 +40,22 @@ protected Warning createWarning(final Matcher matcher) {
String message = matcher.group(4);
Priority priority;

String category;
StringBuilder category = new StringBuilder();
if (ERROR.equalsIgnoreCase(matcher.group(3))) {
priority = Priority.HIGH;
category = "Error";
category.append("Error");
}
else {
priority = Priority.NORMAL;
category = "Warning";
category.append("Warning");

Pattern classPattern = Pattern.compile("\\[-W(.+)\\]$");
Matcher classMatcher = classPattern.matcher(message);
Matcher classMatcher = CLASS_PATTERN.matcher(message);
if (classMatcher.find() && classMatcher.group(1) != null) {
category += ":" + classMatcher.group(1);
category.append(":").append(classMatcher.group(1));
}
}

return createWarning(fileName, lineNumber, category, message, priority);
return createWarning(fileName, lineNumber, category.toString(), message, priority);
}
}

Expand Up @@ -21,6 +21,7 @@
*/
public class DynamicParserTest extends PhpParserTest {
private static final String TYPE = "PHP Runtime";
private static final String NEW_LINE = System.getProperty("line.separator");

@Override
protected AbstractWarningsParser createParser() {
Expand Down Expand Up @@ -107,9 +108,8 @@ public void issueReadFromFile() throws IOException {

StringPluginLogger logger = new StringPluginLogger("warnings");
Collection<FileAnnotation> warnings = registry.parse(file, logger);
String newLine = System.getProperty("line.separator");

assertEquals("Wrong logging message", "[warnings] issue11926 : Found 4 warnings." + newLine, logger.toString());
assertEquals("Wrong logging message", "[warnings] issue11926 : Found 4 warnings." + NEW_LINE, logger.toString());
assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 1, warnings.size());
}

Expand Down

0 comments on commit b137e72

Please sign in to comment.