Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[FIXED JENKINS-11799] improve warning category for gcc 4.6 or later.
  • Loading branch information
johnou committed Jan 13, 2013
1 parent 04da997 commit b137e727fc6fb4ecfe6a381e7d514bc4cdf1627d
@@ -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>.
@@ -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);
}
}

@@ -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() {
@@ -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());
}

0 comments on commit b137e72

Please sign in to comment.