mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 01:06:01 +02:00
update error parser junits to read a set of files with output to feed parser
current and only file contains build output which causes to error parser to hang
This commit is contained in:
parent
67a47ed1f9
commit
2ff46eeeab
6 changed files with 662 additions and 161 deletions
|
@ -10,14 +10,12 @@
|
|||
###############################################################################
|
||||
bin.includes = plugin.xml,\
|
||||
about.html,\
|
||||
plugin.properties,\
|
||||
cdtcoretests.jar,\
|
||||
test.xml,\
|
||||
resources/,\
|
||||
META-INF/
|
||||
src.includes = plugin.properties
|
||||
|
||||
output.cdtcoretests.jar = bin/
|
||||
about.html =
|
||||
source.cdtcoretests.jar = failures/,\
|
||||
model/,\
|
||||
parser/,\
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package org.eclipse.cdt.core.internal.errorparsers.tests;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
|
||||
public class ErrorParserTests {
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(ErrorParserTests.class.getName());
|
||||
|
||||
// Just add more test cases here as you create them for
|
||||
// each class being tested
|
||||
suite.addTest(GCCErrorParserTests.suite());
|
||||
suite.addTest(FileBasedErrorParserTests.suite());
|
||||
return suite;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package org.eclipse.cdt.core.internal.errorparsers.tests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
public class FileBasedErrorParserTests extends GenericErrorParserTests {
|
||||
|
||||
File errorFile;
|
||||
|
||||
public FileBasedErrorParserTests(File file) {
|
||||
super("testErrorsInFiles");
|
||||
errorFile = file;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return super.getName() + " " + errorFile.getName();
|
||||
}
|
||||
|
||||
public void testErrorsInFiles() throws IOException {
|
||||
InputStream stream = new FileInputStream(errorFile);
|
||||
|
||||
runParserTest(stream, -1, -1, null, null, new String[]{GCC_ERROR_PARSER_ID});
|
||||
stream.close();
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(FileBasedErrorParserTests.class.getName());
|
||||
File dir = CTestPlugin.getDefault().getFileInPlugin(new Path("resources/errortests/"));
|
||||
File[] testsfiles = dir.listFiles();
|
||||
for (int i = 0; i < testsfiles.length; i++) {
|
||||
suite.addTest(new FileBasedErrorParserTests(testsfiles[i]));
|
||||
}
|
||||
return suite;
|
||||
}
|
||||
}
|
|
@ -10,157 +10,86 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.internal.errorparsers.tests;
|
||||
|
||||
import java.io.StringBufferInputStream;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.ErrorParserManager;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* This test is designed to exercise the error parser capabilities.
|
||||
*/
|
||||
public class GCCErrorParserTests extends GenericErrorParserTests {
|
||||
public static final String GCC_ERROR_PARSER_ID = "org.eclipse.cdt.core.GCCErrorParser";
|
||||
public static final String [] GCC_ERROR_STREAM1 = {
|
||||
"qcc -c -I/qnx630/target/qnx6/usr/include -I/qnx630/target/qnx6/usr/include/photon -V3.3.1,gcc_ntox86 -w5 -O2 -I. ../abmain.c abmain.o",
|
||||
"In file included from ../globals.h:9,",
|
||||
" from ../abmain.c:36:",
|
||||
"../_combolist.h:34:24: warning: no newline at end of file",
|
||||
};
|
||||
|
||||
public static final String[] GCC_ERROR_STREAM1 = {
|
||||
"qcc -c -I/qnx630/target/qnx6/usr/include -I/qnx630/target/qnx6/usr/include/photon -V3.3.1,gcc_ntox86 -w5 -O2 -I. ../abmain.c abmain.o",
|
||||
"In file included from ../globals.h:9,", " from ../abmain.c:36:",
|
||||
"../_combolist.h:34:24: warning: no newline at end of file",};
|
||||
public static final int GCC_ERROR_STREAM1_WARNINGS = 1;
|
||||
public static final int GCC_ERROR_STREAM1_ERRORS = 0;
|
||||
public static final String [] GCC_ERROR_STREAM1_FILENAMES = { "_combolist.h" };
|
||||
public static final String[] GCC_ERROR_STREAM1_FILENAMES = {"_combolist.h"};
|
||||
|
||||
public static final String [] GCC_ERROR_STREAM2 = {
|
||||
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:234: warning: `",
|
||||
" RPNEvaluator<NumericType>::OperandConstant' is implicitly a typename",
|
||||
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:234: warning: implicit typename",
|
||||
" is deprecated, please see the documentation for details"
|
||||
};
|
||||
public static final String[] GCC_ERROR_STREAM2 = {"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:234: warning: `",
|
||||
" RPNEvaluator<NumericType>::OperandConstant' is implicitly a typename",
|
||||
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:234: warning: implicit typename",
|
||||
" is deprecated, please see the documentation for details"};
|
||||
public static final int GCC_ERROR_STREAM2_WARNINGS = 2;
|
||||
public static final int GCC_ERROR_STREAM2_ERRORS = 0;
|
||||
public static final String [] GCC_ERROR_STREAM2_FILENAMES = { "RPNEvaluator.hpp" };
|
||||
public static final String [] GCC_ERROR_STREAM2_DESCRIPTIONS = { "please see the documentation" };
|
||||
|
||||
public static final String [] GCC_ERROR_STREAM3 = {
|
||||
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:370: error: ISO C++ says that `",
|
||||
" char& String::operator[](unsigned int)' and `operator[]' are ambiguous even ",
|
||||
" though the worst conversion for the former is better than the worst ",
|
||||
" conversion for the latter"
|
||||
};
|
||||
public static final String[] GCC_ERROR_STREAM2_FILENAMES = {"RPNEvaluator.hpp"};
|
||||
public static final String[] GCC_ERROR_STREAM2_DESCRIPTIONS = {"please see the documentation"};
|
||||
|
||||
public static final String[] GCC_ERROR_STREAM3 = {
|
||||
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:370: error: ISO C++ says that `",
|
||||
" char& String::operator[](unsigned int)' and `operator[]' are ambiguous even ",
|
||||
" though the worst conversion for the former is better than the worst ", " conversion for the latter"};
|
||||
public static final int GCC_ERROR_STREAM3_WARNINGS = 0;
|
||||
public static final int GCC_ERROR_STREAM3_ERRORS = 1;
|
||||
public static final String [] GCC_ERROR_STREAM3_FILENAMES = { "RPNEvaluator.hpp" };
|
||||
public static final String [] GCC_ERROR_STREAM3_DESCRIPTIONS = { "ISO C++", "are ambiguous", "worst conversion", "conversion for the latter" };
|
||||
public static final String[] GCC_ERROR_STREAM3_FILENAMES = {"RPNEvaluator.hpp"};
|
||||
public static final String[] GCC_ERROR_STREAM3_DESCRIPTIONS = {"ISO C++", "are ambiguous", "worst conversion",
|
||||
"conversion for the latter"};
|
||||
|
||||
public static final String [] GCC_ERROR_STREAM4 = {
|
||||
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp: In member function `",
|
||||
" NumericType RPNEvaluator<NumericType>::evaluate(const char*) [with ",
|
||||
" NumericType = int8]':",
|
||||
"C:/QNX630/workspace/System/src/CommonScriptClasses.cpp:609: instantiated from here",
|
||||
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:370: error: ISO C++ says that `",
|
||||
" char& String::operator[](unsigned int)' and `operator[]' are ambiguous even ",
|
||||
" though the worst conversion for the former is better than the worst ",
|
||||
" conversion for the latter"
|
||||
};
|
||||
public static final String[] GCC_ERROR_STREAM4 = {"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp: In member function `",
|
||||
" NumericType RPNEvaluator<NumericType>::evaluate(const char*) [with ", " NumericType = int8]':",
|
||||
"C:/QNX630/workspace/System/src/CommonScriptClasses.cpp:609: instantiated from here",
|
||||
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:370: error: ISO C++ says that `",
|
||||
" char& String::operator[](unsigned int)' and `operator[]' are ambiguous even ",
|
||||
" though the worst conversion for the former is better than the worst ", " conversion for the latter"};
|
||||
public static final int GCC_ERROR_STREAM4_WARNINGS = 0;
|
||||
public static final int GCC_ERROR_STREAM4_ERRORS = 1;
|
||||
public static final String [] GCC_ERROR_STREAM4_FILENAMES = { "RPNEvaluator.hpp" };
|
||||
public static final String [] GCC_ERROR_STREAM4_DESCRIPTIONS = { "ISO C++", "are ambiguous", "worst conversion for", "conversion for the latter" };
|
||||
|
||||
public static final String[] GCC_ERROR_STREAM4_FILENAMES = {"RPNEvaluator.hpp"};
|
||||
public static final String[] GCC_ERROR_STREAM4_DESCRIPTIONS = {"ISO C++", "are ambiguous", "worst conversion for",
|
||||
"conversion for the latter"};
|
||||
|
||||
/**
|
||||
* Constructor for IndexManagerTest.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public GCCErrorParserTests(String name) {
|
||||
super(name);
|
||||
public GCCErrorParserTests() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(GCCErrorParserTests.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
|
||||
public void testMultipleIncludesError() {
|
||||
runParserTest(GCC_ERROR_STREAM1,
|
||||
GCC_ERROR_STREAM1_ERRORS,
|
||||
GCC_ERROR_STREAM1_WARNINGS,
|
||||
GCC_ERROR_STREAM1_FILENAMES,
|
||||
null);
|
||||
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() {
|
||||
runParserTest(GCC_ERROR_STREAM2,
|
||||
GCC_ERROR_STREAM2_ERRORS,
|
||||
GCC_ERROR_STREAM2_WARNINGS,
|
||||
GCC_ERROR_STREAM2_FILENAMES,
|
||||
GCC_ERROR_STREAM2_DESCRIPTIONS);
|
||||
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() {
|
||||
runParserTest(GCC_ERROR_STREAM3,
|
||||
GCC_ERROR_STREAM3_ERRORS,
|
||||
GCC_ERROR_STREAM3_WARNINGS,
|
||||
GCC_ERROR_STREAM3_FILENAMES,
|
||||
GCC_ERROR_STREAM3_DESCRIPTIONS);
|
||||
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() {
|
||||
runParserTest(GCC_ERROR_STREAM4,
|
||||
GCC_ERROR_STREAM4_ERRORS,
|
||||
GCC_ERROR_STREAM4_WARNINGS,
|
||||
GCC_ERROR_STREAM4_FILENAMES,
|
||||
GCC_ERROR_STREAM4_DESCRIPTIONS);
|
||||
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});
|
||||
}
|
||||
|
||||
private void runParserTest(String [] dataStream,
|
||||
int expectedErrorCount,
|
||||
int expectedWarningCount,
|
||||
String [] expectedFileNames,
|
||||
String [] expectedDescriptions ) {
|
||||
String [] parserID = { GCC_ERROR_PARSER_ID };
|
||||
CountingMarkerGenerator markerGenerator = new CountingMarkerGenerator();
|
||||
|
||||
IProject project = getTempProject();
|
||||
assertNotNull(project);
|
||||
|
||||
ErrorParserManager manager;
|
||||
manager = new ImaginaryFilesErrorParserManager(project, markerGenerator, parserID);
|
||||
|
||||
String errorStream = makeStringFromArray(dataStream, "\n");
|
||||
StringBufferInputStream inputStream = new StringBufferInputStream(errorStream);
|
||||
assertNotNull(inputStream);
|
||||
|
||||
try {
|
||||
transferInputStreamToOutputStream(inputStream, manager.getOutputStream(), 1024);
|
||||
} catch(Exception ex) {
|
||||
assertTrue(false);
|
||||
} finally {
|
||||
try {
|
||||
manager.close();
|
||||
} catch(Exception ex) {
|
||||
/* Ignore */
|
||||
}
|
||||
}
|
||||
manager.reportProblems();
|
||||
|
||||
assertEquals(expectedErrorCount, markerGenerator.numErrors);
|
||||
assertEquals(expectedWarningCount, markerGenerator.numWarnings);
|
||||
assertEquals(expectedFileNames.length, markerGenerator.uniqFiles.size());
|
||||
for(int i= 0; i < expectedFileNames.length; i++) {
|
||||
IPath path = ((IFile)markerGenerator.uniqFiles.get(i)).getLocation();
|
||||
assertEquals(expectedFileNames[i], path.lastSegment());
|
||||
}
|
||||
|
||||
if(expectedDescriptions != null) {
|
||||
assertNotNull(markerGenerator.lastDescription);
|
||||
for(int i = 0; i < expectedDescriptions.length; i++) {
|
||||
assertTrue(markerGenerator.lastDescription.matches(expectedDescriptions[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,10 +10,10 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.internal.errorparsers.tests;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringBufferInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -33,27 +33,34 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
* This test is designed to exercise the error parser capabilities.
|
||||
*/
|
||||
public class GenericErrorParserTests extends TestCase {
|
||||
public static final String GCC_ERROR_PARSER_ID = "org.eclipse.cdt.core.GCCErrorParser";
|
||||
|
||||
protected IProject fTempProject;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for IndexManagerTest.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public GenericErrorParserTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public GenericErrorParserTests() {
|
||||
super();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
super.setUp();
|
||||
fTempProject = ResourcesPlugin.getWorkspace().getRoot().getProject("temp-" + System.currentTimeMillis());
|
||||
if(!fTempProject.exists()) {
|
||||
if (!fTempProject.exists()) {
|
||||
fTempProject.create(new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see TestCase#tearDown()
|
||||
*/
|
||||
|
@ -67,15 +74,15 @@ public class GenericErrorParserTests extends TestCase {
|
|||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected IProject getTempProject() {
|
||||
return fTempProject;
|
||||
}
|
||||
|
||||
protected String makeStringFromArray(String [] pieces, String sep) {
|
||||
protected String makeStringFromArray(String[] pieces, String sep) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for(int i = 0; i < pieces.length; i++) {
|
||||
if(i != 0) {
|
||||
for (int i = 0; i < pieces.length; i++) {
|
||||
if (i != 0) {
|
||||
buf.append(sep);
|
||||
}
|
||||
buf.append(pieces[i]);
|
||||
|
@ -84,18 +91,78 @@ public class GenericErrorParserTests extends TestCase {
|
|||
}
|
||||
|
||||
protected void transferInputStreamToOutputStream(InputStream input, OutputStream output, int byteBlockSize) throws IOException {
|
||||
byte [] buffer = new byte[byteBlockSize];
|
||||
int bytesRead;
|
||||
|
||||
while((bytesRead = input.read(buffer)) >= 0) {
|
||||
byte[] buffer = new byte[byteBlockSize];
|
||||
int bytesRead;
|
||||
|
||||
while ( (bytesRead = input.read(buffer)) >= 0) {
|
||||
output.write(buffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
|
||||
buffer = null;
|
||||
}
|
||||
|
||||
|
||||
protected void runParserTest(InputStream inputStream, int expectedErrorCount, int expectedWarningCount,
|
||||
String[] expectedFileNames, String[] expectedDescriptions, String[] parserID) {
|
||||
|
||||
assertNotNull(inputStream);
|
||||
|
||||
CountingMarkerGenerator markerGenerator = new CountingMarkerGenerator();
|
||||
|
||||
IProject project = getTempProject();
|
||||
assertNotNull(project);
|
||||
|
||||
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) {
|
||||
assertEquals(expectedErrorCount, markerGenerator.numErrors);
|
||||
}
|
||||
if (expectedWarningCount >= 0) {
|
||||
assertEquals(expectedWarningCount, markerGenerator.numWarnings);
|
||||
}
|
||||
if (expectedFileNames != null) {
|
||||
assertEquals(expectedFileNames.length, markerGenerator.uniqFiles.size());
|
||||
for (int i = 0; i < expectedFileNames.length; i++) {
|
||||
IPath path = ((IFile)markerGenerator.uniqFiles.get(i)).getLocation();
|
||||
assertEquals(expectedFileNames[i], path.lastSegment());
|
||||
}
|
||||
}
|
||||
|
||||
if (expectedDescriptions != null) {
|
||||
assertNotNull(markerGenerator.lastDescription);
|
||||
for (int i = 0; i < expectedDescriptions.length; i++) {
|
||||
assertTrue(markerGenerator.lastDescription.matches(expectedDescriptions[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void runParserTest(String[] dataStream, int expectedErrorCount, int expectedWarningCount, String[] expectedFileNames,
|
||||
String[] expectedDescriptions, String[] parserID) {
|
||||
String errorStream = makeStringFromArray(dataStream, "\n");
|
||||
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(errorStream.getBytes());
|
||||
|
||||
runParserTest(inputStream, expectedErrorCount, expectedWarningCount, expectedFileNames, expectedDescriptions, parserID);
|
||||
}
|
||||
|
||||
class FileNameComparator implements Comparator {
|
||||
/* (non-Javadoc)
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public int compare(Object arg0, Object arg1) {
|
||||
|
@ -103,40 +170,41 @@ public class GenericErrorParserTests extends TestCase {
|
|||
IFile f0 = (IFile)arg0;
|
||||
IFile f1 = (IFile)arg1;
|
||||
return f0.getName().compareToIgnoreCase(f1.getName());
|
||||
} catch(Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
/* Ignore */
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Expand and grow this class to make it more usefull.
|
||||
*/
|
||||
class CountingMarkerGenerator implements IMarkerGenerator {
|
||||
|
||||
public int numErrors;
|
||||
public int numWarnings;
|
||||
public int numMarkers;
|
||||
public ArrayList uniqFiles;
|
||||
public String lastDescription;
|
||||
private Comparator fFileNameComparator;
|
||||
|
||||
public String lastDescription;
|
||||
private Comparator fFileNameComparator;
|
||||
|
||||
public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {
|
||||
int index = Collections.binarySearch(uniqFiles, file, fFileNameComparator);
|
||||
if(index < 0) {
|
||||
uniqFiles.add(-1*(index + 1), file);
|
||||
if (index < 0) {
|
||||
uniqFiles.add(-1 * (index + 1), file);
|
||||
}
|
||||
|
||||
if(severity == SEVERITY_WARNING) {
|
||||
|
||||
if (severity == SEVERITY_WARNING) {
|
||||
numWarnings++;
|
||||
} else if(severity == SEVERITY_ERROR_BUILD || severity == SEVERITY_ERROR_RESOURCE) {
|
||||
} else if (severity == SEVERITY_ERROR_BUILD || severity == SEVERITY_ERROR_RESOURCE) {
|
||||
numErrors++;
|
||||
}
|
||||
|
||||
|
||||
lastDescription = errorDesc;
|
||||
numMarkers++;
|
||||
}
|
||||
|
||||
|
||||
public CountingMarkerGenerator() {
|
||||
numErrors = 0;
|
||||
numWarnings = 0;
|
||||
|
@ -146,46 +214,47 @@ public class GenericErrorParserTests extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* This class allows us to run error parsers for files which don't
|
||||
* really exist by just using the strings that come out as error codes.
|
||||
*/
|
||||
* This class allows us to run error parsers for files which don't really
|
||||
* exist by just using the strings that come out as error codes.
|
||||
*/
|
||||
class ImaginaryFilesErrorParserManager extends ErrorParserManager {
|
||||
|
||||
IProject fProject;
|
||||
|
||||
public ImaginaryFilesErrorParserManager(IProject project, IMarkerGenerator generator, String [] ids) {
|
||||
|
||||
public ImaginaryFilesErrorParserManager(IProject project, IMarkerGenerator generator, String[] ids) {
|
||||
super(project, generator, ids);
|
||||
fProject = project;
|
||||
}
|
||||
|
||||
|
||||
public IFile findFileName(String fileName) {
|
||||
if(fileName.lastIndexOf('/') != -1) {
|
||||
fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
|
||||
if (fileName.lastIndexOf('/') != -1) {
|
||||
fileName = fileName.substring(fileName.lastIndexOf('/') + 1);
|
||||
}
|
||||
IFile file = fProject.getFile(fileName);
|
||||
if(!file.exists()) {
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
InputStream stream = new StringBufferInputStream("TestFile");
|
||||
InputStream stream = new ByteArrayInputStream("TestFile".getBytes());
|
||||
file.create(stream, true, new NullProgressMonitor());
|
||||
stream.close();
|
||||
} catch(Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
/* Ignore */
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
protected IFile findFileInWorkspace(IPath path) {
|
||||
IFile file = fProject.getFile(path.lastSegment());
|
||||
if(!file.exists()) {
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
InputStream stream = new StringBufferInputStream("TestFile");
|
||||
InputStream stream = new ByteArrayInputStream("TestFile".getBytes());
|
||||
file.create(stream, true, new NullProgressMonitor());
|
||||
stream.close();
|
||||
} catch(Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
/* Ignore */
|
||||
}
|
||||
}
|
||||
return file;
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
443
core/org.eclipse.cdt.core.tests/resources/errortests/output-1
Normal file
443
core/org.eclipse.cdt.core.tests/resources/errortests/output-1
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue