Index: src/main/java/hudson/plugins/warnings/parser/GccIncludeParser.java
===================================================================
--- src/main/java/hudson/plugins/warnings/parser/GccIncludeParser.java (revision 0)
+++ src/main/java/hudson/plugins/warnings/parser/GccIncludeParser.java (revision 0)
@@ -0,0 +1,79 @@
+package hudson.plugins.warnings.parser;
+
+import hudson.plugins.warnings.util.model.Priority;
+
+import java.util.regex.Matcher;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * A parser for the gcc compiler -include - warnings.
+ */
+public class GccIncludeParser extends RegexpLineParser {
+ /** Warning type of this parser. */
+ static final String WARNING_TYPE = "gcc-include";
+ /** Pattern of gcc compiler - include - warnings. */
+
+
+ /**
+ * 1. Checks only for warning
+ */
+
+ private static final String GCC_INCLUDE_WARNING_PATTERN = "^(?: ) from (.+):([0-9]+):$";
+
+
+
+ /**
+ * 2. Checks for warnings and information
+ *
+
+ private static final String GCC_INCLUDE_WARNING_PATTERN = "^(?:In file included| ) from (.+):([0-9]+)(?:(:)|(,))?";
+
+ *
+ */
+
+
+
+ /**
+ * Creates a new instance of GccIncludeParser
.
+ */
+ public GccIncludeParser() {
+ super(GCC_INCLUDE_WARNING_PATTERN, "GNU compiler (gcc-include)");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected Warning createWarning(final Matcher matcher) {
+ Priority priority;
+ String category;
+
+ /**
+ * 1. Checks only for warning
+ */
+
+ priority = Priority.NORMAL;
+ category = "GCC INCLUDE warning";
+
+
+
+ /**
+ * 2. Checks for warnings and information
+ *
+
+ if (":".equalsIgnoreCase(matcher.group(3))) {
+ priority = Priority.NORMAL;
+ category = "GCC INCLUDE warning";
+ }
+ else{
+ priority = Priority.LOW;
+ category = "GCC INCLUDE information";
+ }
+
+ *
+ */
+
+ return new Warning(matcher.group(1), getLineNumber(matcher.group(2)), WARNING_TYPE,
+ category, "One of the files included there generated a GCC warning or error - See console log for more information", priority);
+
+ }
+}
Index: src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java
===================================================================
--- src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java (revision 21459)
+++ src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java (working copy)
@@ -252,6 +252,7 @@
parsers.add(new AntEclipseParser());
parsers.add(new MsBuildParser());
parsers.add(new GccParser());
+ parsers.add(new GccIncludeParser());
parsers.add(new InvalidsParser());
parsers.add(new SunCParser());
parsers.add(new GnatParser());
Index: src/test/java/hudson/plugins/warnings/parser/GccIncludeParserTest.java
===================================================================
--- src/test/java/hudson/plugins/warnings/parser/GccIncludeParserTest.java (revision 0)
+++ src/test/java/hudson/plugins/warnings/parser/GccIncludeParserTest.java (revision 0)
@@ -0,0 +1,91 @@
+package hudson.plugins.warnings.parser;
+
+import static junit.framework.Assert.*;
+import hudson.plugins.warnings.util.model.FileAnnotation;
+import hudson.plugins.warnings.util.model.Priority;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.junit.Test;
+
+/**
+ * Tests the class {@link GccIncludeParser}.
+ */
+public class GccIncludeParserTest extends ParserTester {
+ /** Error message. */
+ private static final String WRONG_NUMBER_OF_WARNINGS_DETECTED = "Wrong number of warnings detected.";
+ /** An error. */
+ private static final String GCC_INCLUDE_ERROR = "GCC INCLUDE error";
+ /** A warning. */
+ private static final String GCC_INCLUDE_WARNING = "GCC INCLUDE warning";
+ /** Information. */
+ private static final String GCC_INCLUDE_INFO = "GCC INCLUDE information";
+
+
+ /**
+ * Creates a new instance of {@link GccIncludeParserTest}.
+ */
+ public GccIncludeParserTest() {
+ super(GccIncludeParser.class);
+ }
+
+ /**
+ * Parses a file with three GCC include warnings.
+ *
+ * @throws IOException
+ * if the file could not be read
+ */
+ @Test
+ public void testWarningsParser() throws IOException {
+ Collection warnings = new GccIncludeParser().parse(openFile());
+
+ assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 1, warnings.size());
+
+ /**
+ *
+
+ assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 3, warnings.size());
+
+ *
+ */
+
+ Iterator iterator = warnings.iterator();
+ FileAnnotation annotation = iterator.next();
+
+ /**
+ *
+
+ checkWarning(annotation,
+ 4,
+ "One of the files included there generated a GCC warning or error - See console log for more information",
+ "/usr/include/c++/3.3/backward/warn.h",
+ GccIncludeParser.WARNING_TYPE, GCC_INCLUDE_INFO, Priority.LOW);
+ annotation = iterator.next();
+ checkWarning(annotation,
+ 31,
+ "One of the files included there generated a GCC warning or error - See console log for more information",
+ "/usr/include/c++/3.3/backward/iostream.h",
+ GccIncludeParser.WARNING_TYPE, GCC_INCLUDE_INFO, Priority.LOW);
+ annotation = iterator.next();
+
+ *
+ */
+
+ checkWarning(annotation,
+ 1,
+ "One of the files included there generated a GCC warning or error - See console log for more information",
+ "test_clt.cc",
+ GccIncludeParser.WARNING_TYPE, GCC_INCLUDE_WARNING, Priority.NORMAL);
+ }
+
+
+
+ /** {@inheritDoc} */
+ @Override
+ protected String getWarningsFile() {
+ return "gcc-include.txt";
+ }
+}
+
Index: src/test/java/hudson/plugins/warnings/parser/ParserRegistryTest.java
===================================================================
--- src/test/java/hudson/plugins/warnings/parser/ParserRegistryTest.java (revision 21459)
+++ src/test/java/hudson/plugins/warnings/parser/ParserRegistryTest.java (working copy)
@@ -22,7 +22,7 @@
*/
public class ParserRegistryTest {
/** Total number of expected warnings. */
- private static final int TOTAL_WARNINGS = 176;
+ private static final int TOTAL_WARNINGS = 177;
/** Error message. */
private static final String WRONG_NUMBER_OF_ANNOTATIONS_PARSED = "Wrong number of annotations parsed";
Index: src/test/resources/hudson/plugins/warnings/parser/all.txt
===================================================================
--- src/test/resources/hudson/plugins/warnings/parser/all.txt (revision 21459)
+++ src/test/resources/hudson/plugins/warnings/parser/all.txt (working copy)
@@ -718,3 +718,8 @@
All warning where generate by compiling ObjectiveC Code (see the *.m in the File-Names)
+
+
+In file included from /usr/include/c++/3.3/backward/warn.h:4,
+ from /usr/include/c++/3.3/backward/iostream.h:31,
+ from test_clt.cc:1:
Index: src/test/resources/hudson/plugins/warnings/parser/gcc-include.txt
===================================================================
--- src/test/resources/hudson/plugins/warnings/parser/gcc-include.txt (revision 0)
+++ src/test/resources/hudson/plugins/warnings/parser/gcc-include.txt (revision 0)
@@ -0,0 +1,6 @@
+
+
+
+In file included from /usr/include/c++/3.3/backward/warn.h:4,
+ from /usr/include/c++/3.3/backward/iostream.h:31,
+ from test_clt.cc:1: