Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[JENKINS-11799] Classify warnings by gcc 4.6 or later.
  • Loading branch information
yoichi committed Jan 12, 2013
1 parent 206694f commit 04da9970e546183c1c1d3e204c7b8254525de241
@@ -4,6 +4,7 @@
import hudson.plugins.analysis.util.model.Priority;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* A parser for gcc 4.x compiler warnings.
@@ -46,6 +47,12 @@ protected Warning createWarning(final Matcher matcher) {
else {
priority = Priority.NORMAL;
category = "Warning";

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

return createWarning(fileName, lineNumber, category, message, priority);
@@ -187,6 +187,42 @@ public void issue5870() throws IOException {
assertEquals(THERE_ARE_WARNINGS_FOUND, 0, warnings.size());
}

/**
* Classify warnings by gcc 4.6 or later.
*
* @throws IOException
* if the file could not be read
* @see <a href="https://issues.jenkins-ci.org/browse/JENKINS-11799">Issue 11799</a>
*/
@Test
public void issue11799() throws IOException {
Collection<FileAnnotation> warnings = new Gcc4CompilerParser().parse(openFile("issue11799.txt"));

assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 4, warnings.size());
Iterator<FileAnnotation> iterator = warnings.iterator();

checkWarning(iterator.next(),
4,
"implicit declaration of function 'undeclared_function' [-Wimplicit-function-declaration]",
"gcc4warning.c",
WARNING_TYPE, WARNING_CATEGORY + ":implicit-function-declaration", Priority.NORMAL);
checkWarning(iterator.next(),
3,
"unused variable 'unused_local' [-Wunused-variable]",
"gcc4warning.c",
WARNING_TYPE, WARNING_CATEGORY + ":unused-variable", Priority.NORMAL);
checkWarning(iterator.next(),
1,
"unused parameter 'unused_parameter' [-Wunused-parameter]",
"gcc4warning.c",
WARNING_TYPE, WARNING_CATEGORY + ":unused-parameter", Priority.NORMAL);
checkWarning(iterator.next(),
5,
"control reaches end of non-void function [-Wreturn-type]",
"gcc4warning.c",
WARNING_TYPE, WARNING_CATEGORY + ":return-type", Priority.NORMAL);
}

@Override
protected String getWarningsFile() {
return "gcc4.txt";
@@ -0,0 +1,6 @@
================ gcc 4.6 warnings
gcc4warning.c: In function 'gcc4warning':
gcc4warning.c:4:2: warning: implicit declaration of function 'undeclared_function' [-Wimplicit-function-declaration]
gcc4warning.c:3:6: warning: unused variable 'unused_local' [-Wunused-variable]
gcc4warning.c:1:21: warning: unused parameter 'unused_parameter' [-Wunused-parameter]
gcc4warning.c:5:1: warning: control reaches end of non-void function [-Wreturn-type]

0 comments on commit 04da997

Please sign in to comment.