Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[FIXED JENKINS-12482] Improved regular expression of JavaC parser to
support Java 7 compiler format.
  • Loading branch information
uhafner committed Feb 20, 2012
1 parent 82b0b4c commit bf57fb2ccd81975749a6ce821e1b08d114bd3ce8
@@ -11,7 +11,7 @@ public class JavacParser extends RegexpLineParser {
/** Warning type of this parser. */
static final String WARNING_TYPE = "Java Compiler";
/** Pattern of javac compiler warnings. */
private static final String JAVAC_WARNING_PATTERN = "^\\[WARNING\\]\\s*(.*):\\[(\\d*)[.,; 0-9]*\\]\\s*(?:\\[(\\w*)\\])?\\s*(.*)$";
private static final String JAVAC_WARNING_PATTERN = "^(?:\\[WARNING\\]\\s+)?(.*):\\[(\\d*)[.,; 0-9]*\\]\\s*(?:\\[(\\w*)\\])?\\s*(.*)$";

/**
* Creates a new instance of <code>JavacParser</code>.
@@ -23,7 +23,7 @@ public JavacParser() {
/** {@inheritDoc} */
@Override
protected boolean isLineInteresting(final String line) {
return line.contains("[WARNING]");
return line.contains("[");
}

/**
@@ -14,6 +14,24 @@
* Tests the class {@link JavacParser}.
*/
public class JavacParserTest extends ParserTester {
/**
* Parses a warning log with 15 warnings.
*
* @throws IOException
* if the file could not be read
* @see <a href="http://issues.jenkins-ci.org/browse/JENKINS-12482">Issue 12482</a>
*/
@Test
public void issue12482() throws IOException {
Collection<FileAnnotation> java6 = parse("issue12482-java6.txt");

assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 62, java6.size());

Collection<FileAnnotation> java7 = parse("issue12482-java7.txt");

assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 62, java7.size());
}

/**
* Parses a file with two deprecation warnings.
*
@@ -48,7 +66,7 @@ public void parseDeprecation() throws IOException {
*/
@Test
public void parseArrayInDeprecatedMethod() throws IOException {
Collection<FileAnnotation> warnings = new JavacParser().parse(openFile("issue5868.txt"));
Collection<FileAnnotation> warnings = parse("issue5868.txt");

assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 1, warnings.size());

@@ -60,6 +78,10 @@ public void parseArrayInDeprecatedMethod() throws IOException {
AntJavacParser.WARNING_TYPE, "Deprecation", Priority.NORMAL);
}

protected Collection<FileAnnotation> parse(final String fileName) throws IOException {
return new JavacParser().parse(openFile(fileName));
}

/** {@inheritDoc} */
@Override
protected String getWarningsFile() {

0 comments on commit bf57fb2

Please sign in to comment.