mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 134310 - Fix the GCC error parser which was really slow on long command lines. Now if the line is longer than a magic number (1000 for now), it is skipped since it's not likely to be an error message.
Bug 143952 - Skipping over "instantiated from here" so that it doesn't appear as an error.
This commit is contained in:
parent
6c4db4a4b8
commit
316f28e9c0
5 changed files with 20 additions and 20 deletions
|
@ -36,6 +36,7 @@ public class FileBasedErrorParserTests extends GenericErrorParserTests {
|
|||
File dir = CTestPlugin.getDefault().getFileInPlugin(new Path("resources/errortests/"));
|
||||
File[] testsfiles = dir.listFiles();
|
||||
for (int i = 0; i < testsfiles.length; i++) {
|
||||
if (testsfiles[i].isFile())
|
||||
suite.addTest(new FileBasedErrorParserTests(testsfiles[i]));
|
||||
}
|
||||
return suite;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
package org.eclipse.cdt.core.internal.errorparsers.tests;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
|
@ -73,22 +75,22 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
|
|||
return suite;
|
||||
}
|
||||
|
||||
public void testMultipleIncludesError() {
|
||||
public void testMultipleIncludesError() throws IOException {
|
||||
runParserTest(GCC_ERROR_STREAM1, GCC_ERROR_STREAM1_ERRORS, GCC_ERROR_STREAM1_WARNINGS, GCC_ERROR_STREAM1_FILENAMES, null,
|
||||
new String[]{GCC_ERROR_PARSER_ID});
|
||||
}
|
||||
|
||||
public void testMultiLineDescriptionError() {
|
||||
public void testMultiLineDescriptionError() throws IOException {
|
||||
runParserTest(GCC_ERROR_STREAM2, GCC_ERROR_STREAM2_ERRORS, GCC_ERROR_STREAM2_WARNINGS, GCC_ERROR_STREAM2_FILENAMES,
|
||||
GCC_ERROR_STREAM2_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
|
||||
}
|
||||
|
||||
public void testLongMultiLineDescriptionError() {
|
||||
public void testLongMultiLineDescriptionError() throws IOException {
|
||||
runParserTest(GCC_ERROR_STREAM3, GCC_ERROR_STREAM3_ERRORS, GCC_ERROR_STREAM3_WARNINGS, GCC_ERROR_STREAM3_FILENAMES,
|
||||
GCC_ERROR_STREAM3_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
|
||||
}
|
||||
|
||||
public void testMultiFileMultiLineSingleError() {
|
||||
public void testMultiFileMultiLineSingleError() throws IOException {
|
||||
runParserTest(GCC_ERROR_STREAM4, GCC_ERROR_STREAM4_ERRORS, GCC_ERROR_STREAM4_WARNINGS, GCC_ERROR_STREAM4_FILENAMES,
|
||||
GCC_ERROR_STREAM4_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ public class GenericErrorParserTests extends TestCase {
|
|||
}
|
||||
|
||||
protected void runParserTest(InputStream inputStream, int expectedErrorCount, int expectedWarningCount,
|
||||
String[] expectedFileNames, String[] expectedDescriptions, String[] parserID) {
|
||||
String[] expectedFileNames, String[] expectedDescriptions, String[] parserID) throws IOException {
|
||||
|
||||
assertNotNull(inputStream);
|
||||
|
||||
|
@ -114,17 +114,8 @@ public class GenericErrorParserTests extends TestCase {
|
|||
ErrorParserManager manager;
|
||||
manager = new ImaginaryFilesErrorParserManager(project, markerGenerator, parserID);
|
||||
|
||||
try {
|
||||
transferInputStreamToOutputStream(inputStream, manager.getOutputStream(), 1024);
|
||||
} catch (Exception ex) {
|
||||
assertTrue(false);
|
||||
} finally {
|
||||
try {
|
||||
manager.close();
|
||||
} catch (Exception ex) {
|
||||
/* Ignore */
|
||||
}
|
||||
}
|
||||
manager.reportProblems();
|
||||
|
||||
if (expectedErrorCount >= 0) {
|
||||
|
@ -150,7 +141,7 @@ public class GenericErrorParserTests extends TestCase {
|
|||
}
|
||||
|
||||
protected void runParserTest(String[] dataStream, int expectedErrorCount, int expectedWarningCount, String[] expectedFileNames,
|
||||
String[] expectedDescriptions, String[] parserID) {
|
||||
String[] expectedDescriptions, String[] parserID) throws IOException {
|
||||
String errorStream = makeStringFromArray(dataStream, "\n");
|
||||
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(errorStream.getBytes());
|
||||
|
|
|
@ -187,6 +187,11 @@ public class ErrorParserManager extends OutputStream {
|
|||
if (fErrorParsers.size() == 0)
|
||||
return;
|
||||
|
||||
// If the line is too long, it is most likely a command line and not an error message
|
||||
// Don't process it since it'll probably be really slow and won't find an error anyway
|
||||
if (line.length() > 1000)
|
||||
return;
|
||||
|
||||
String[] parserIDs = new String[fErrorParsers.size()];
|
||||
Iterator items = fErrorParsers.keySet().iterator();
|
||||
for (int i = 0; items.hasNext(); i++) {
|
||||
|
|
|
@ -30,8 +30,9 @@ public class GCCErrorParser extends AbstractErrorParser {
|
|||
new ErrorPattern("\\(Each undeclared identifier is reported only once"),
|
||||
new ErrorPattern("for each function it appears in.\\)"),
|
||||
new ErrorPattern(": note:"),
|
||||
new ErrorPattern("instantiated from here"),
|
||||
// The following are not...
|
||||
new ErrorPattern("((.:)?[^:]*):([0-9]*):([0-9]*:)? ((warning: )?.*)", 1, 3, 5, 0, 0) {
|
||||
new ErrorPattern("(.*?):([0-9]+):([0-9]+:)? ((warning: )?.*)", 1, 2, 4, 0, 0) {
|
||||
public String getVarName(Matcher matcher) {
|
||||
String desc = getDesc(matcher);
|
||||
Matcher varMatcher = null;
|
||||
|
@ -46,7 +47,7 @@ public class GCCErrorParser extends AbstractErrorParser {
|
|||
return varMatcher != null ? varMatcher.group(1) : null;
|
||||
}
|
||||
public int getSeverity(Matcher matcher) {
|
||||
String warningGroup = matcher.group(6);
|
||||
String warningGroup = matcher.group(5);
|
||||
if (warningGroup != null)
|
||||
return IMarkerGenerator.SEVERITY_WARNING;
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue