mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Convert more of the tests to JUnit5
Some of these tests left behind projects, by chaning them to extend BaseTestCase5 the resource cleanup happens and the tests are cleaned up properly Part of #117
This commit is contained in:
parent
73d74a1db6
commit
e1dea25b40
16 changed files with 334 additions and 339 deletions
|
@ -51,4 +51,6 @@ Bundle-Vendor: %providerName
|
|||
Bundle-RequiredExecutionEnvironment: JavaSE-17
|
||||
Automatic-Module-Name: org.eclipse.cdt.core.tests
|
||||
Bundle-Localization: plugin
|
||||
Import-Package: org.junit.jupiter.api;version="5.7.0"
|
||||
Import-Package: org.junit.jupiter.api;version="5.9.0",
|
||||
org.junit.jupiter.params;version="5.9.0",
|
||||
org.junit.jupiter.params.provider;version="5.9.0"
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.envvar;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -22,6 +27,7 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
|||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||
import org.eclipse.cdt.core.testplugin.ResourceHelper;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
|
||||
import org.eclipse.cdt.utils.envvar.IEnvironmentChangeEvent;
|
||||
import org.eclipse.cdt.utils.envvar.IEnvironmentChangeListener;
|
||||
|
@ -32,12 +38,9 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
|||
import org.eclipse.core.runtime.jobs.IJobManager;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class IEnvironmentVariableManagerTests extends TestCase {
|
||||
public class IEnvironmentVariableManagerTests extends BaseTestCase5 {
|
||||
/**
|
||||
* Mock listener to listen to environment variable change events.
|
||||
*/
|
||||
|
@ -65,26 +68,12 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp(getName());
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(IEnvironmentVariableManagerTests.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a project with 2 configurations. Set an environment variable on one of
|
||||
* the configurations. Close and reopen the project. Check persistence
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testSimpleVar() throws Exception {
|
||||
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
|
||||
|
||||
|
@ -138,6 +127,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
* Also tests that an an external change to the settings file is correctly picked up.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testOldStyleLoad() throws Exception {
|
||||
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProjectOldStyleLoad");
|
||||
|
||||
|
@ -178,6 +168,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
* Tests we can load an old-style preferences while an incompatible scheduling rule is held.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testOldStyleLoadConflictingSchedulingRule() throws Exception {
|
||||
final IProject project = ResourceHelper.createCDTProjectWithConfig("incompatibleSchedRule");
|
||||
|
||||
|
@ -245,6 +236,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
* Test that an ovewrite of new style preferences is loaded correctly
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testNewStyleOverwrite() throws Exception {
|
||||
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProjectNewStyleLoad");
|
||||
|
||||
|
@ -285,6 +277,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
assertEquals(var2, envManager.getVariable(var2.getName(), prjDesc.getConfigurationById(id2), true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoChangeToOneVariable() throws Exception {
|
||||
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
|
||||
|
||||
|
@ -344,6 +337,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
/**
|
||||
* tests the get / set append persisting
|
||||
*/
|
||||
@Test
|
||||
public void testGetSetAppend() throws Exception {
|
||||
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
|
||||
|
||||
|
@ -387,6 +381,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
/**
|
||||
* Tests file system change of the settings file
|
||||
*/
|
||||
@Test
|
||||
public void testSettingsOverwrite() throws Exception {
|
||||
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
|
||||
|
||||
|
@ -436,6 +431,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
/**
|
||||
* Tests file system change of the settings file without recreating the project description
|
||||
*/
|
||||
@Test
|
||||
public void testSettingsOverwriteBug295436() throws Exception {
|
||||
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
|
||||
|
||||
|
@ -493,6 +489,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
* Test that on deleting and recreating the project variables haven't persisted
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testBrokenCaching() throws Exception {
|
||||
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
|
||||
|
||||
|
@ -537,6 +534,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
* The model shouldn't cache incorrect variables / values in the project description
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testBug265282() throws Exception {
|
||||
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
|
||||
|
||||
|
@ -625,6 +623,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testBug284843() throws Exception {
|
||||
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
|
||||
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
|
||||
|
@ -678,6 +677,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testEnvironmentChangeListener() throws Exception {
|
||||
// Register environment event listener
|
||||
MockEnvironmentListener envListener = new MockEnvironmentListener();
|
||||
|
|
|
@ -13,17 +13,19 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.internal.efsextension.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.cdt.utils.EFSExtensionManager;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests the EFSExtensionManager and EFSExtensionProvider classes, as well as the EFSExtensionProvider extension point.
|
||||
|
@ -31,7 +33,8 @@ import junit.framework.TestSuite;
|
|||
* @author crecoskie
|
||||
*
|
||||
*/
|
||||
public class EFSExtensionTests extends TestCase {
|
||||
public class EFSExtensionTests extends BaseTestCase5 {
|
||||
@Test
|
||||
public void testReplaceInRSEURI() {
|
||||
URI originalURI = null;
|
||||
URI expected = null;
|
||||
|
@ -49,6 +52,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertEquals(expected, uri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplaceInUNIXURI() {
|
||||
URI originalURI = null;
|
||||
URI expected = null;
|
||||
|
@ -66,6 +70,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertEquals(expected, uri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplaceInWindowsURI() {
|
||||
URI originalURI = null;
|
||||
URI expected = null;
|
||||
|
@ -83,6 +88,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertEquals(expected, uri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplaceInMadeUpURI() {
|
||||
URI originalURI = null;
|
||||
URI expected = null;
|
||||
|
@ -100,6 +106,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertEquals(expected, uri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplaceWithWindowsPathNoLeadingSlash() {
|
||||
URI originalURI = null;
|
||||
URI expected = null;
|
||||
|
@ -123,6 +130,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertEquals(expected, uri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplaceURIWithAuthority() {
|
||||
URI originalURI = null;
|
||||
URI expected = null;
|
||||
|
@ -141,6 +149,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertEquals(expected, uri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplaceURIWithAuthority2() {
|
||||
URI originalURI = null;
|
||||
URI expected = null;
|
||||
|
@ -159,6 +168,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertEquals(expected, uri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppendinRSEURI() {
|
||||
URI originalURI = null;
|
||||
URI expected = null;
|
||||
|
@ -174,6 +184,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertEquals(expected, uri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppendToUNIXURI() {
|
||||
URI originalURI = null;
|
||||
URI expected = null;
|
||||
|
@ -189,6 +200,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertEquals(expected, uri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppendToWindowsURI() {
|
||||
URI originalURI = null;
|
||||
URI expected = null;
|
||||
|
@ -204,6 +216,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertEquals(expected, uri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLinkedURI() {
|
||||
URI originalURI = null;
|
||||
try {
|
||||
|
@ -217,6 +230,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertEquals(originalURI, uri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMappedPath() {
|
||||
URI originalURI = null;
|
||||
try {
|
||||
|
@ -234,6 +248,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPathFromURI() {
|
||||
URI originalURI = null;
|
||||
try {
|
||||
|
@ -251,6 +266,7 @@ public class EFSExtensionTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtension() {
|
||||
URI originalURI = null;
|
||||
try {
|
||||
|
@ -262,8 +278,4 @@ public class EFSExtensionTests extends TestCase {
|
|||
assertTrue(EFSExtensionManager.getDefault().isVirtual(originalURI));
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(EFSExtensionTests.class);
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
|
||||
package org.eclipse.cdt.core.internal.errorparsers.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
|
@ -27,6 +31,7 @@ import org.eclipse.cdt.core.errorparsers.AbstractErrorParser;
|
|||
import org.eclipse.cdt.core.errorparsers.ErrorPattern;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.ResourceHelper;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.core.internal.registry.ExtensionRegistry;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -36,16 +41,14 @@ import org.eclipse.core.runtime.IContributor;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* The test case includes a few tests checking that {@link AbstractErrorParser}/{@link ErrorPattern}
|
||||
* properly locate and resolve filenames found in build output in case of EFS files/folders.
|
||||
*/
|
||||
public class ErrorParserEfsFileMatchingTest extends TestCase {
|
||||
public class ErrorParserEfsFileMatchingTest extends BaseTestCase5 {
|
||||
private static final String MAKE_ERRORPARSER_ID = "org.eclipse.cdt.core.CWDLocator";
|
||||
private String mockErrorParserId = null;
|
||||
|
||||
|
@ -80,47 +83,16 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param name - name of the test.
|
||||
*/
|
||||
public ErrorParserEfsFileMatchingTest(String name) {
|
||||
super(name);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
protected void beforeEach() throws Exception {
|
||||
if (fProject == null) {
|
||||
fProject = ResourceHelper.createCDTProject(testName);
|
||||
Assert.assertNotNull(fProject);
|
||||
assertNotNull(fProject);
|
||||
mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class);
|
||||
}
|
||||
errorList = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp(getName());
|
||||
fProject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return - new TestSuite.
|
||||
*/
|
||||
public static TestSuite suite() {
|
||||
return new TestSuite(ErrorParserEfsFileMatchingTest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* main function of the class.
|
||||
*
|
||||
* @param args - arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(suite());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Error Parser extension to the global repository.
|
||||
* Note that this function will "pollute" the working environment and
|
||||
|
@ -138,7 +110,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
boolean added = Platform.getExtensionRegistry().addContribution(new ByteArrayInputStream(ext.getBytes()),
|
||||
contributor, false, shortId, null,
|
||||
((ExtensionRegistry) Platform.getExtensionRegistry()).getTemporaryUserToken());
|
||||
assertTrue("failed to add extension", added);
|
||||
assertTrue(added, "failed to add extension");
|
||||
String fullId = "org.eclipse.cdt.core.tests." + shortId;
|
||||
IErrorParser[] errorParser = CCorePlugin.getDefault().getErrorParser(fullId);
|
||||
assertTrue(errorParser.length > 0);
|
||||
|
@ -210,6 +182,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testSingle() throws Exception {
|
||||
ResourceHelper.createEfsFile(fProject, "testSingle.c", "null:/efsTestSingle.c");
|
||||
|
||||
|
@ -225,6 +198,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testEfsVsRegular() throws Exception {
|
||||
ResourceHelper.createFile(fProject, "testEfsVsRegular.c");
|
||||
ResourceHelper.createEfsFile(fProject, "efsTestEfsVsRegular.c", "null:/testEfsVsRegular.c");
|
||||
|
@ -241,6 +215,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testFullPath() throws Exception {
|
||||
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
|
||||
ResourceHelper.createEfsFile(fProject, "Folder/testFullPath.c", "null:/EfsFolder/efsTestFullPath.c");
|
||||
|
@ -258,6 +233,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testInNonEfsFolder() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "NonEfsFolder");
|
||||
ResourceHelper.createEfsFile(fProject, "NonEfsFolder/testInNonEfsFolder.c",
|
||||
|
@ -276,6 +252,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testInFolder() throws Exception {
|
||||
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
|
||||
ResourceHelper.createEfsFile(fProject, "Folder/testInFolder.c", "null:/EfsFolder/efsTestInFolder.c");
|
||||
|
@ -293,6 +270,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicateInRoot() throws Exception {
|
||||
ResourceHelper.createEfsFile(fProject, "testDuplicateInRoot.c", "null:/testDuplicateInRoot.c");
|
||||
|
||||
|
@ -313,6 +291,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathFromProjectRoot() throws Exception {
|
||||
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
|
||||
ResourceHelper.createEfsFile(fProject, "Folder/testRelativePathFromProjectRoot.c",
|
||||
|
@ -332,6 +311,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathFromSubfolder() throws Exception {
|
||||
ResourceHelper.createEfsFolder(fProject, "Subfolder", "null:/Subfolder");
|
||||
ResourceHelper.createEfsFolder(fProject, "Subfolder/Folder", "null:/Subfolder/Folder");
|
||||
|
@ -352,6 +332,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathNotMatchingFolder() throws Exception {
|
||||
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
|
||||
ResourceHelper.createEfsFile(fProject, "Folder/testRelativePathNotMatchingFolder.c",
|
||||
|
@ -372,6 +353,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathDuplicate() throws Exception {
|
||||
ResourceHelper.createEfsFolder(fProject, "SubfolderA", "null:/SubfolderA");
|
||||
ResourceHelper.createEfsFolder(fProject, "SubfolderA/Folder", "null:/SubfolderA/Folder");
|
||||
|
@ -397,6 +379,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathUpSubfolder() throws Exception {
|
||||
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
|
||||
ResourceHelper.createEfsFile(fProject, "Folder/testRelativePathUpSubfolder.c",
|
||||
|
@ -416,6 +399,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathDotFromSubfolder() throws Exception {
|
||||
ResourceHelper.createEfsFolder(fProject, "Subfolder", "null:/Subfolder");
|
||||
ResourceHelper.createEfsFolder(fProject, "Subfolder/Folder", "null:/Subfolder/Folder");
|
||||
|
@ -436,6 +420,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testBuildDir() throws Exception {
|
||||
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
|
||||
ResourceHelper.createEfsFile(fProject, "Folder/testBuildDir.c", "null:/Folder/testBuildDir.c");
|
||||
|
@ -456,9 +441,10 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testEfsProject() throws Exception {
|
||||
IFile efsSmokeTest = ResourceHelper.createEfsFile(fProject, "efsSmokeTest.c", "mem:/efsSmokeTest.c");
|
||||
Assert.assertTrue(efsSmokeTest.exists());
|
||||
assertTrue(efsSmokeTest.exists());
|
||||
|
||||
IProject efsProject = ResourceHelper.createCDTProject("EfsProject", new URI("mem:/EfsProject"));
|
||||
ResourceHelper.createFolder(efsProject, "Folder");
|
||||
|
@ -476,6 +462,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testEfsProjectBuildDirURI() throws Exception {
|
||||
String fileName = "testEfsProjectBuildDirURI.c";
|
||||
|
||||
|
@ -499,6 +486,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testEfsProjectPushPopDirectory() throws Exception {
|
||||
String fileName = "testEfsProjectPushPopDirectory.c";
|
||||
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
|
||||
package org.eclipse.cdt.core.internal.errorparsers.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -27,6 +31,7 @@ import org.eclipse.cdt.core.errorparsers.AbstractErrorParser;
|
|||
import org.eclipse.cdt.core.errorparsers.ErrorPattern;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.ResourceHelper;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.cdt.internal.core.Cygwin;
|
||||
import org.eclipse.core.internal.registry.ExtensionRegistry;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
@ -39,16 +44,14 @@ import org.eclipse.core.runtime.IContributor;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* The test case includes a few tests checking that {@link AbstractErrorParser}/{@link ErrorPattern}
|
||||
* properly locate and resolve filenames found in build output.
|
||||
*/
|
||||
public class ErrorParserFileMatchingTest extends TestCase {
|
||||
public class ErrorParserFileMatchingTest extends BaseTestCase5 {
|
||||
private static final String CWD_LOCATOR_ID = "org.eclipse.cdt.core.CWDLocator";
|
||||
private String mockErrorParserId = null;
|
||||
|
||||
|
@ -83,47 +86,14 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param name - name of the test.
|
||||
*/
|
||||
public ErrorParserFileMatchingTest(String name) {
|
||||
super(name);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
if (fProject == null) {
|
||||
@BeforeEach
|
||||
protected void beforeEach() throws Exception {
|
||||
fProject = ResourceHelper.createCDTProject(testName);
|
||||
Assert.assertNotNull(fProject);
|
||||
assertNotNull(fProject);
|
||||
mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class);
|
||||
}
|
||||
errorList = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp(getName());
|
||||
fProject = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return - new TestSuite.
|
||||
*/
|
||||
public static TestSuite suite() {
|
||||
return new TestSuite(ErrorParserFileMatchingTest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* main function of the class.
|
||||
*
|
||||
* @param args - arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(suite());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Error Parser extension to the global repository.
|
||||
* Note that this function will "pollute" the working environment and
|
||||
|
@ -141,7 +111,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
boolean added = Platform.getExtensionRegistry().addContribution(new ByteArrayInputStream(ext.getBytes()),
|
||||
contributor, false, shortId, null,
|
||||
((ExtensionRegistry) Platform.getExtensionRegistry()).getTemporaryUserToken());
|
||||
assertTrue("failed to add extension", added);
|
||||
assertTrue(added, "failed to add extension");
|
||||
String fullId = "org.eclipse.cdt.core.tests." + shortId;
|
||||
IErrorParser[] errorParser = CCorePlugin.getDefault().getErrorParser(fullId);
|
||||
assertTrue(errorParser.length > 0);
|
||||
|
@ -194,6 +164,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testSingle() throws Exception {
|
||||
ResourceHelper.createFile(fProject, "testSingle.c");
|
||||
|
||||
|
@ -210,6 +181,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks that no false positive for missing file generated.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testMissing() throws Exception {
|
||||
|
||||
parseOutput("testMissing.c:1:error");
|
||||
|
@ -227,6 +199,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if duplicate files give ambiguous match.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicate() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "FolderA");
|
||||
ResourceHelper.createFile(fProject, "FolderA/testDuplicate.c");
|
||||
|
@ -248,6 +221,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testInFolder() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
ResourceHelper.createFile(fProject, "Folder/testInFolder.c");
|
||||
|
@ -264,6 +238,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicateInRoot() throws Exception {
|
||||
ResourceHelper.createFile(fProject, "testDuplicateInRoot.c");
|
||||
|
||||
|
@ -284,6 +259,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testLinkedFile() throws Exception {
|
||||
ResourceHelper.createWorkspaceFolder("OutsideFolder");
|
||||
IPath realFile = ResourceHelper.createWorkspaceFile("OutsideFolder/testLinkedFile.c");
|
||||
|
@ -302,6 +278,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testLinkedFileWithDifferentName() throws Exception {
|
||||
ResourceHelper.createWorkspaceFolder("OutsideFolder");
|
||||
IPath realFile = ResourceHelper.createWorkspaceFile("OutsideFolder/RealFileWithDifferentName.c");
|
||||
|
@ -321,6 +298,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicateLinkedFile() throws Exception {
|
||||
ResourceHelper.createWorkspaceFolder("OutsideFolderA");
|
||||
ResourceHelper.createWorkspaceFolder("OutsideFolderB");
|
||||
|
@ -346,6 +324,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicateLinkedFileDifferentName() throws Exception {
|
||||
ResourceHelper.createWorkspaceFolder("OutsideFolderA");
|
||||
ResourceHelper.createWorkspaceFolder("OutsideFolderB");
|
||||
|
@ -370,6 +349,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testInLinkedFolder() throws Exception {
|
||||
IPath outsideFolder = ResourceHelper.createWorkspaceFolder("OutsideFolder");
|
||||
ResourceHelper.createWorkspaceFile("OutsideFolder/testInLinkedFolder.c");
|
||||
|
@ -387,6 +367,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicateInLinkedFolder() throws Exception {
|
||||
IPath folderA = ResourceHelper.createWorkspaceFolder("OutsideFolderA");
|
||||
ResourceHelper.createWorkspaceFile("OutsideFolderA/testDuplicateInLinkedFolder.c");
|
||||
|
@ -410,6 +391,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testLinkedFolderInAnotherProject() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
ResourceHelper.createFile(fProject, "Folder/testLinkedFolderInAnotherProject.c");
|
||||
|
@ -442,6 +424,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testSymbolicLink() throws Exception {
|
||||
// do not test on systems where symbolic links are not supported
|
||||
if (!ResourceHelper.isSymbolicLinkSupported())
|
||||
|
@ -465,6 +448,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicateSymbolicLink() throws Exception {
|
||||
// do not test on systems where symbolic links are not supported
|
||||
if (!ResourceHelper.isSymbolicLinkSupported())
|
||||
|
@ -493,6 +477,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testFolderSymbolicLink() throws Exception {
|
||||
// do not test on systems where symbolic links are not supported
|
||||
if (!ResourceHelper.isSymbolicLinkSupported())
|
||||
|
@ -516,6 +501,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDuplicateFolderSymbolicLink() throws Exception {
|
||||
// do not test on systems where symbolic links are not supported
|
||||
if (!ResourceHelper.isSymbolicLinkSupported())
|
||||
|
@ -541,6 +527,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testAbsolutePathSingle() throws Exception {
|
||||
ResourceHelper.createFile(fProject, "testAbsolutePathSingle.c");
|
||||
String fullName = fProject.getLocation().append("testAbsolutePathSingle.c").toOSString();
|
||||
|
@ -558,6 +545,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testAbsolutePathInOtherProject() throws Exception {
|
||||
IProject anotherProject = ResourceHelper.createCDTProject("ProjectAbsolutePathInOtherProject");
|
||||
ResourceHelper.createFile(anotherProject, "testAbsolutePathInOtherProject.c");
|
||||
|
@ -577,6 +565,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testAbsolutePathOutsideWorkspace() throws Exception {
|
||||
|
||||
ResourceHelper.createWorkspaceFolder("OutsideFolder");
|
||||
|
@ -599,6 +588,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathFromProjectRoot() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
ResourceHelper.createFile(fProject, "Folder/testRelativePathFromProjectRoot.c");
|
||||
|
@ -617,6 +607,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathFromSubfolder() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
ResourceHelper.createFolder(fProject, "Folder/SubFolder");
|
||||
|
@ -636,6 +627,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathNotMatchingFolder() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
ResourceHelper.createFile(fProject, "Folder/testRelativePathNotMatchingFolder.c");
|
||||
|
@ -655,6 +647,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathDuplicate() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "SubfolderA");
|
||||
ResourceHelper.createFolder(fProject, "SubfolderA/Folder");
|
||||
|
@ -678,6 +671,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathUp() throws Exception {
|
||||
ResourceHelper.createFile(fProject, "testRelativePathUp.c");
|
||||
|
||||
|
@ -694,6 +688,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathUpSubfolderBug262988() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
ResourceHelper.createFile(fProject, "Folder/testRelativePathUpSubfolder.c");
|
||||
|
@ -711,6 +706,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathUpOtherProject() throws Exception {
|
||||
IProject anotherProject = ResourceHelper.createCDTProject("AnotherProject");
|
||||
ResourceHelper.createFile(anotherProject, "testRelativePathUpOtherProject.c");
|
||||
|
@ -728,6 +724,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathUpDuplicate() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "FolderA/SubFolder");
|
||||
ResourceHelper.createFolder(fProject, "FolderB/SubFolder");
|
||||
|
@ -749,6 +746,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathDotFromProjectRoot() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
ResourceHelper.createFile(fProject, "Folder/testRelativePathDotFromProjectRoot.c");
|
||||
|
@ -767,6 +765,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathDotFromSubfolder() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Subfolder");
|
||||
ResourceHelper.createFolder(fProject, "Subfolder/Folder");
|
||||
|
@ -786,6 +785,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathDotNotMatchingFolder() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
ResourceHelper.createFile(fProject, "Subfolder/Folder/testRelativePathDotNotMatchingFolder.c");
|
||||
|
@ -806,6 +806,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRelativePathDotDuplicate() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "SubfolderA");
|
||||
ResourceHelper.createFolder(fProject, "SubfolderA/Folder");
|
||||
|
@ -830,6 +831,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testUppercase1() throws Exception {
|
||||
if (!Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
// This test is valid on Windows platform only
|
||||
|
@ -851,6 +853,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testUppercase2InSubFolder() throws Exception {
|
||||
// Note that old MSDOS can handle only 8 characters in file name
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -869,6 +872,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testUppercase3ResolveCase() throws Exception {
|
||||
// Note that old MSDOS can handle only 8 characters in file name
|
||||
ResourceHelper.createFolder(fProject, "FolderA");
|
||||
|
@ -889,6 +893,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testUppercase4Duplicate() throws Exception {
|
||||
// Note that old MSDOS can handle only 8 characters in file name
|
||||
ResourceHelper.createFolder(fProject, "FolderA");
|
||||
|
@ -911,6 +916,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testCygwinCygdrive() throws Exception {
|
||||
String fileName = "testCygwinCygdrive.c";
|
||||
String windowsFileName = fProject.getLocation().append(fileName).toOSString();
|
||||
|
@ -921,7 +927,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
// Skip the test if Cygwin is not available.
|
||||
return;
|
||||
}
|
||||
assertTrue("cygwinFileName=[" + cygwinFileName + "]", cygwinFileName.startsWith("/cygdrive/"));
|
||||
assertTrue(cygwinFileName.startsWith("/cygdrive/"), "cygwinFileName=[" + cygwinFileName + "]");
|
||||
|
||||
ResourceHelper.createFile(fProject, fileName);
|
||||
|
||||
|
@ -938,6 +944,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testCygwinUsrUnclude() throws Exception {
|
||||
String cygwinFolder = "/usr/include/";
|
||||
String fileName = "stdio.h";
|
||||
|
@ -950,11 +957,11 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
return;
|
||||
}
|
||||
|
||||
assertTrue("usrIncludeWindowsPath=[" + usrIncludeWindowsPath + "]",
|
||||
usrIncludeWindowsPath.charAt(1) == IPath.DEVICE_SEPARATOR);
|
||||
assertTrue(usrIncludeWindowsPath.charAt(1) == IPath.DEVICE_SEPARATOR,
|
||||
"usrIncludeWindowsPath=[" + usrIncludeWindowsPath + "]");
|
||||
|
||||
java.io.File file = new java.io.File(usrIncludeWindowsPath + "\\" + fileName);
|
||||
assertTrue("File " + file + " does not exist, check your cygwin installation", file.exists());
|
||||
assertTrue(file.exists(), "File " + file + " does not exist, check your cygwin installation");
|
||||
|
||||
ResourceHelper.createLinkedFolder(fProject, "include", usrIncludeWindowsPath);
|
||||
|
||||
|
@ -971,6 +978,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testCygwinAnotherProject() throws Exception {
|
||||
String fileName = "testCygwinAnotherProject.c";
|
||||
IProject anotherProject = ResourceHelper.createCDTProject("AnotherProject");
|
||||
|
@ -983,7 +991,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
// Skip the test if Cygwin is not available.
|
||||
return;
|
||||
}
|
||||
assertTrue("cygwinFileName=[" + cygwinFileName + "]", cygwinFileName.startsWith("/cygdrive/"));
|
||||
assertTrue(cygwinFileName.startsWith("/cygdrive/"), "cygwinFileName=[" + cygwinFileName + "]");
|
||||
|
||||
ResourceHelper.createFile(anotherProject, fileName);
|
||||
|
||||
|
@ -1000,6 +1008,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testCustomProjectLocation() throws Exception {
|
||||
ResourceHelper.createWorkspaceFolder("Custom");
|
||||
ResourceHelper.createWorkspaceFolder("Custom/ProjectLocation");
|
||||
|
@ -1022,6 +1031,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testCygwinAndMakeErrorParserBug270772() throws Exception {
|
||||
String fileName = "testCygwinAndMakeErrorParser.c";
|
||||
String windowsFileName = fProject.getLocation().append(fileName).toOSString();
|
||||
|
@ -1032,7 +1042,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
// Skip the test if Cygwin is not available.
|
||||
return;
|
||||
}
|
||||
assertTrue("cygwinFileName=[" + cygwinFileName + "]", cygwinFileName.startsWith("/cygdrive/"));
|
||||
assertTrue(cygwinFileName.startsWith("/cygdrive/"), "cygwinFileName=[" + cygwinFileName + "]");
|
||||
|
||||
ResourceHelper.createFile(fProject, fileName);
|
||||
|
||||
|
@ -1052,6 +1062,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testInNestedProject() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "NestedProjectFolder");
|
||||
IProject nestedProject = ResourceHelper.createCDTProject("NestedProject",
|
||||
|
@ -1086,6 +1097,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testBuildDir() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
ResourceHelper.createFile(fProject, "Folder/testBuildDir.c");
|
||||
|
@ -1106,6 +1118,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
* Checks if a file from error output can be found.
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testBuildDirVsProjectRoot() throws Exception {
|
||||
ResourceHelper.createFile(fProject, "testBuildDirVsProjectRoot.c");
|
||||
ResourceHelper.createFolder(fProject, "BuildDir");
|
||||
|
@ -1126,6 +1139,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testAbsoluteFileVsLink() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
IFile file = ResourceHelper.createFile(fProject, "Folder/testAbsoluteFileVsLink.c");
|
||||
|
@ -1146,6 +1160,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testPushDirectory() throws Exception {
|
||||
String fileName = "testPushDirectory.c";
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1170,6 +1185,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testPushDirectorySingleQuote() throws Exception {
|
||||
String fileName = "testPushDirectory.c";
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1193,6 +1209,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testPushAbsoluteDirectory() throws Exception {
|
||||
String fileName = "testPushAbsoluteDirectory.c";
|
||||
IFolder folder = ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1200,7 +1217,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
ResourceHelper.createFile(fProject, "Folder/" + fileName);
|
||||
|
||||
IPath absoluteDir = folder.getLocation();
|
||||
Assert.assertTrue(absoluteDir.isAbsolute());
|
||||
assertTrue(absoluteDir.isAbsolute());
|
||||
|
||||
String lines = "make[0]: Entering directory `" + absoluteDir + "'\n" + fileName + ":1:error\n";
|
||||
|
||||
|
@ -1219,6 +1236,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testPopDirectory() throws Exception {
|
||||
String fileName = "testPopDirectory.c";
|
||||
|
||||
|
@ -1247,6 +1265,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testPushPop_WithNoLevel() throws Exception {
|
||||
String fileName = getName() + ".c";
|
||||
|
||||
|
@ -1275,6 +1294,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testPushDirectoryAndCache() throws Exception {
|
||||
String fileName = "testPushDirectoryCacheProblem.c";
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1307,6 +1327,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDisablePushDirectoryOnParallelBuild_J() throws Exception {
|
||||
String fileName = getName() + ".c";
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1330,6 +1351,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDisablePushDirectoryOnParallelBuild_J2() throws Exception {
|
||||
String fileName = getName() + ".c";
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1353,6 +1375,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDisablePushDirectoryOnParallelBuild_J_2() throws Exception {
|
||||
String fileName = getName() + ".c";
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1376,6 +1399,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDisablePushDirectoryOnParallelBuild_J1() throws Exception {
|
||||
String fileName = getName() + ".c";
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1399,6 +1423,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDisablePushDirectoryOnParallelBuild_J_1() throws Exception {
|
||||
String fileName = getName() + ".c";
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1422,6 +1447,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDisablePushDirectoryOnParallelBuild_Jobs() throws Exception {
|
||||
String fileName = getName() + ".c";
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1445,6 +1471,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDisablePushDirectoryOnParallelBuild_Jobs1() throws Exception {
|
||||
String fileName = getName() + ".c";
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1468,6 +1495,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDisablePushDirectoryOnParallelBuild_gmake() throws Exception {
|
||||
String fileName = getName() + ".c";
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
|
@ -1491,6 +1519,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testMappedRemoteAbsolutePath_Bug264704() throws Exception {
|
||||
ResourceHelper.createFolder(fProject, "Folder");
|
||||
ResourceHelper.createFolder(fProject, "Folder/AbsoluteRemoteFolder");
|
||||
|
@ -1511,6 +1540,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testMappedRemoteAbsolutePathAnotherProject_Bug264704() throws Exception {
|
||||
|
||||
IProject anotherProject = ResourceHelper.createCDTProject("ProjectMappedRemoteAbsolutePathAnotherProject");
|
||||
|
@ -1536,6 +1566,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testWindowsPathOnLinux_Bug263977() throws Exception {
|
||||
// This test is valid on Unix platforms only
|
||||
boolean isUnix = Platform.getOS().equals(Platform.OS_LINUX) || Platform.getOS().equals(Platform.OS_AIX)
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
|
||||
package org.eclipse.cdt.core.internal.errorparsers.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -29,6 +33,7 @@ import org.eclipse.cdt.core.dom.IPDOMManager;
|
|||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.core.internal.registry.ExtensionRegistry;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -42,16 +47,15 @@ import org.eclipse.core.runtime.IContributor;
|
|||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Alena Laskavaia
|
||||
*
|
||||
* Tests for ErrorParser manager and different parsers
|
||||
*/
|
||||
public class ErrorParserManagerTest extends TestCase {
|
||||
public class ErrorParserManagerTest extends BaseTestCase5 {
|
||||
IWorkspace workspace;
|
||||
IWorkspaceRoot root;
|
||||
|
||||
|
@ -61,14 +65,6 @@ public class ErrorParserManagerTest extends TestCase {
|
|||
private ArrayList<ProblemMarkerInfo> errorList;
|
||||
private IMarkerGenerator markerGenerator;
|
||||
|
||||
/**
|
||||
* Constructor for CModelTests.
|
||||
* @param name
|
||||
*/
|
||||
public ErrorParserManagerTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the test fixture.
|
||||
*
|
||||
|
@ -77,8 +73,8 @@ public class ErrorParserManagerTest extends TestCase {
|
|||
* Example code test the packages in the project
|
||||
* "com.qnx.tools.ide.cdt.core"
|
||||
*/
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
protected void beforeEach() throws Exception {
|
||||
/***
|
||||
* The test of the tests assume that they have a working workspace
|
||||
* and workspace root object to use to create projects/files in,
|
||||
|
@ -115,24 +111,6 @@ public class ErrorParserManagerTest extends TestCase {
|
|||
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, errorParsersIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the test fixture.
|
||||
*
|
||||
* Called after every test case method.
|
||||
*/
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
// release resources here and clean-up
|
||||
}
|
||||
|
||||
public static TestSuite suite() {
|
||||
return new TestSuite(ErrorParserManagerTest.class);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(suite());
|
||||
}
|
||||
|
||||
private ICProject createProject(String name) throws CoreException {
|
||||
ICProject testProject;
|
||||
testProject = CProjectHelper.createCProject(name, "none", IPDOMManager.ID_NO_INDEXER);
|
||||
|
@ -152,6 +130,7 @@ public class ErrorParserManagerTest extends TestCase {
|
|||
epManager.getOutputStream().close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsersSanity() throws CoreException, IOException {
|
||||
output("catchpoints.cpp:12: warning: no return statement in function returning non-void\n");
|
||||
end();
|
||||
|
@ -162,6 +141,7 @@ public class ErrorParserManagerTest extends TestCase {
|
|||
assertEquals(new Path("catchpoints.cpp"), problemMarkerInfo.externalPath);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsersSanityTrimmed() throws CoreException, IOException {
|
||||
output(" catchpoints.cpp:12: warning: no return statement in function returning non-void \n");
|
||||
end();
|
||||
|
@ -172,6 +152,7 @@ public class ErrorParserManagerTest extends TestCase {
|
|||
assertEquals(new Path("catchpoints.cpp"), problemMarkerInfo.externalPath);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutput() throws IOException {
|
||||
try (FileInputStream fileInputStream = new FileInputStream(
|
||||
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/errortests/output-1")))) {
|
||||
|
@ -195,7 +176,7 @@ public class ErrorParserManagerTest extends TestCase {
|
|||
boolean added = Platform.getExtensionRegistry().addContribution(new ByteArrayInputStream(ext.getBytes()),
|
||||
contributor, false, shortId, null,
|
||||
((ExtensionRegistry) Platform.getExtensionRegistry()).getTemporaryUserToken());
|
||||
assertTrue("failed to add extension", added);
|
||||
assertTrue(added, "failed to add extension");
|
||||
String fullId = "org.eclipse.cdt.core.tests." + shortId;
|
||||
IErrorParser[] errorParser = CCorePlugin.getDefault().getErrorParser(fullId);
|
||||
assertTrue(errorParser.length > 0);
|
||||
|
@ -227,6 +208,7 @@ public class ErrorParserManagerTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoTrimParser() throws IOException {
|
||||
String id = addErrorParserExtension("test1", TestParser1.class);
|
||||
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id });
|
||||
|
@ -256,6 +238,7 @@ public class ErrorParserManagerTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongLinesParser() throws IOException {
|
||||
String id = addErrorParserExtension("test2", TestParser2.class);
|
||||
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id });
|
||||
|
@ -293,6 +276,7 @@ public class ErrorParserManagerTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongLinesUntrimmedParser() throws IOException {
|
||||
String id = addErrorParserExtension("test3", TestParser3.class);
|
||||
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id });
|
||||
|
@ -323,6 +307,7 @@ public class ErrorParserManagerTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWorkspaceLevelError() throws IOException {
|
||||
String id = addErrorParserExtension("test4", TestParser4.class);
|
||||
epManager = new ErrorParserManager(null, markerGenerator, new String[] { id });
|
||||
|
|
|
@ -17,42 +17,27 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
public class FileBasedErrorParserTests extends GenericErrorParserTests {
|
||||
|
||||
File errorFile;
|
||||
|
||||
public FileBasedErrorParserTests(File file) {
|
||||
super("testErrorsInFiles");
|
||||
errorFile = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return super.getName() + " " + errorFile.getName();
|
||||
}
|
||||
|
||||
public void testErrorsInFiles() throws IOException {
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideFilenames")
|
||||
public void testErrorsInFiles(File errorFile) 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());
|
||||
public static Stream<Arguments> provideFilenames() {
|
||||
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;
|
||||
return Stream.of(testsfiles).map(Arguments::of);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@ package org.eclipse.cdt.core.internal.errorparsers.tests;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* This test is designed to exercise the error parser capabilities.
|
||||
|
@ -76,20 +75,7 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
|
|||
public static final int GCC_ERROR_STREAM5_ERRORS = 2;
|
||||
public static final String[] GCC_ERROR_STREAM5_FILENAMES = { "main.c" };
|
||||
|
||||
/**
|
||||
* Constructor for IndexManagerTest.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public GCCErrorParserTests() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(GCCErrorParserTests.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
@Test
|
||||
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 });
|
||||
|
@ -105,27 +91,29 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
|
|||
* I brought this up in http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg08668.html
|
||||
* but did not get any replies.
|
||||
*
|
||||
public void testMultiLineDescriptionError() throws IOException {
|
||||
@Test 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() throws IOException {
|
||||
@Test 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() throws IOException {
|
||||
@Test 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});
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testBasicMessages() throws IOException {
|
||||
runParserTest(GCC_ERROR_STREAM5, GCC_ERROR_STREAM5_ERRORS, GCC_ERROR_STREAM5_WARNINGS,
|
||||
GCC_ERROR_STREAM5_FILENAMES, null, new String[] { GCC_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGccErrorMessages_Colon_bug263987() throws IOException {
|
||||
runParserTest(new String[] {
|
||||
"foo.cc:11:20: error: value with length 0 violates the length restriction: length (1 .. infinity)", },
|
||||
|
@ -136,6 +124,7 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GCC_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGccErrorMessages_C90Comments_bug193982() throws IOException {
|
||||
runParserTest(
|
||||
new String[] { "Myfile.c:66:3: warning: C++ style comments are not allowed in ISO C90",
|
||||
|
@ -146,6 +135,7 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GCC_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGccErrorMessages_ConflictingTypes() throws IOException {
|
||||
runParserTest(
|
||||
new String[] { "bar.h:42: error: conflicting types for 'jmp_buf'",
|
||||
|
@ -157,6 +147,7 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GCC_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGccErrorMessages_InstantiatedFromHere() throws IOException {
|
||||
runParserTest(new String[] {
|
||||
"/usr/include/c++/4.1.3/ext/hashtable.h:600: instantiated from 'size_t __gnu_cxx::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>::_M_bkt_num(const _Val&, size_t) const [with _Val = std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int>, _Key = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _HashFcn = __gnu_cxx::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _ExtractKey = std::_Select1st<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int> >, _EqualKey = std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, _Alloc = std::allocator<int>]'",
|
||||
|
@ -170,6 +161,7 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GCC_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGccErrorMessages_RequiredFromHere() throws IOException {
|
||||
runParserTest(new String[] {
|
||||
"utils/bar.hpp:61:7: required from 'static void OpenCVUtils::show_contours_d(std::string, cv::Mat&, const std::vector<std::vector<cv::Point_<_Tp> > >&, bool, const Scalar&, int, int, int) [with T = int; std::string = std::basic_string<char>; cv::Scalar = cv::Scalar_<double>]'",
|
||||
|
@ -183,6 +175,7 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GCC_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGccErrorMessages_Infos() throws IOException {
|
||||
runParserTest(
|
||||
new String[] { "foo.c:5: note: Offset of packed bit-field 'b' has changed in GCC 4.4",
|
||||
|
@ -196,6 +189,7 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GCC_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGccErrorMessages_DangerousFunction_bug248669() throws IOException {
|
||||
runParserTest(
|
||||
new String[] { "mktemp.o(.text+0x19): In function 'main':",
|
||||
|
@ -206,6 +200,7 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GCC_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGccErrorMessages_TemplateInstantiation_bug500798() throws IOException {
|
||||
runParserTest(new String[] {
|
||||
"test.hpp:309:18: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]",
|
||||
|
@ -219,6 +214,7 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GCC_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGccErrorMessages_InConstexprExpansion() throws IOException {
|
||||
runParserTest(
|
||||
new String[] { "../can/CANBus.h: In instantiation of 'constexpr void Test::setupBitrate(T)':",
|
||||
|
|
|
@ -15,23 +15,14 @@ package org.eclipse.cdt.core.internal.errorparsers.tests;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* This test is designed to exercise the error parser capabilities for GNU ld.
|
||||
*/
|
||||
public class GLDErrorParserTests extends GenericErrorParserTests {
|
||||
|
||||
public GLDErrorParserTests() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(GLDErrorParserTests.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkerMessages0() throws IOException {
|
||||
runParserTest(
|
||||
// old style: no colons before sections
|
||||
|
@ -48,6 +39,7 @@ public class GLDErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GLD_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkerMessages1() throws IOException {
|
||||
runParserTest(
|
||||
// new style: colons before sections
|
||||
|
@ -64,6 +56,7 @@ public class GLDErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GLD_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkerMessages2() throws IOException {
|
||||
runParserTest(
|
||||
new String[] { "make -k all", "gcc -o hallo.o main.c libfoo.a", "libfoo.a(foo.o): In function `foo':",
|
||||
|
@ -76,6 +69,7 @@ public class GLDErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GLD_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkerMessages_DangerousFunction_bug248669() throws IOException {
|
||||
runParserTest(new String[] { "mktemp.o(.text+0x19): In function 'main':",
|
||||
"mktemp.c:15: the use of 'mktemp' is dangerous, better use 'mkstemp'", "1.o: In function `main':",
|
||||
|
@ -88,6 +82,7 @@ public class GLDErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GLD_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkerMessages_PrecedingPath_bug314253() throws IOException {
|
||||
runParserTest(new String[] {
|
||||
"ld: warning: libstdc++.so.5, needed by testlib_1.so, may conflict with libstdc++.so.6",
|
||||
|
@ -107,6 +102,7 @@ public class GLDErrorParserTests extends GenericErrorParserTests {
|
|||
new String[] { GLD_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkerMessages_bug495661() throws IOException {
|
||||
runParserTest(
|
||||
// new style: colons before sections
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.internal.errorparsers.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -25,57 +29,38 @@ import java.util.List;
|
|||
import org.eclipse.cdt.core.ErrorParserManager;
|
||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||
import org.eclipse.cdt.core.ProblemMarkerInfo;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
/**
|
||||
* This test is designed to exercise the error parser capabilities.
|
||||
*/
|
||||
public abstract class GenericErrorParserTests extends TestCase {
|
||||
public abstract class GenericErrorParserTests extends BaseTestCase5 {
|
||||
public static final String GCC_ERROR_PARSER_ID = "org.eclipse.cdt.core.GCCErrorParser";
|
||||
public static final String GLD_ERROR_PARSER_ID = "org.eclipse.cdt.core.GLDErrorParser";
|
||||
public static final String GMAKE_ERROR_PARSER_ID = "org.eclipse.cdt.core.GmakeErrorParser";
|
||||
|
||||
protected IProject fTempProject;
|
||||
|
||||
/**
|
||||
* Constructor for IndexManagerTest.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public GenericErrorParserTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public GenericErrorParserTests() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@BeforeEach
|
||||
protected void beforeEachCreateProject() throws Exception {
|
||||
fTempProject = ResourcesPlugin.getWorkspace().getRoot().getProject("temp-" + System.currentTimeMillis());
|
||||
if (!fTempProject.exists()) {
|
||||
fTempProject.create(new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() {
|
||||
try {
|
||||
super.tearDown();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
try {
|
||||
@AfterEach
|
||||
protected void afterEachDeleteProject() throws CoreException {
|
||||
fTempProject.delete(true, true, new NullProgressMonitor());
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
protected IProject getTempProject() {
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.internal.errorparsers.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.core.ErrorParserManager;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* This test is designed to exercise the error parser capabilities for GNU make.
|
||||
|
@ -66,29 +66,24 @@ public class MakeErrorParserTests extends GenericErrorParserTests {
|
|||
private static final int GMAKE_ERROR_STREAM2_WARNINGS = 0;
|
||||
private static final int GMAKE_ERROR_STREAM2_ERRORS = 3;
|
||||
|
||||
public MakeErrorParserTests() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(MakeErrorParserTests.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGmakeSanity() throws Exception {
|
||||
assertNotNull(ErrorParserManager.getErrorParserCopy(GMAKE_ERROR_PARSER_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGmakeMessages0() throws IOException {
|
||||
runParserTest(GMAKE_ERROR_STREAM0, GMAKE_ERROR_STREAM0_ERRORS, GMAKE_ERROR_STREAM0_WARNINGS,
|
||||
GMAKE_ERROR_STREAM0_INFOS, null, null, new String[] { GMAKE_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGMakeMessages1() throws IOException {
|
||||
runParserTest(GMAKE_ERROR_STREAM1, GMAKE_ERROR_STREAM1_ERRORS, GMAKE_ERROR_STREAM1_WARNINGS,
|
||||
GMAKE_ERROR_STREAM1_FILENAMES, null, new String[] { GMAKE_ERROR_PARSER_ID });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGmakeMessages2() throws IOException {
|
||||
runParserTest(GMAKE_ERROR_STREAM2, GMAKE_ERROR_STREAM2_ERRORS, GMAKE_ERROR_STREAM2_WARNINGS, null, null,
|
||||
new String[] { GMAKE_ERROR_PARSER_ID });
|
||||
|
|
|
@ -14,6 +14,13 @@
|
|||
|
||||
package org.eclipse.cdt.core.internal.errorparsers.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
@ -27,19 +34,20 @@ import org.eclipse.cdt.core.errorparsers.RegexErrorParser;
|
|||
import org.eclipse.cdt.core.errorparsers.RegexErrorPattern;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.ResourceHelper;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.cdt.internal.errorparsers.ErrorParserExtensionManager;
|
||||
import org.eclipse.cdt.internal.errorparsers.GASErrorParser;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test cases testing RegexErrorParser functionality
|
||||
*/
|
||||
public class RegexErrorParserTests extends TestCase {
|
||||
public class RegexErrorParserTests extends BaseTestCase5 {
|
||||
// These should match id and name of extension point defined in plugin.xml
|
||||
private static final String REGEX_ERRORPARSER_ID = "org.eclipse.cdt.core.tests.RegexErrorParserId";
|
||||
private static final String REGEX_ERRORPARSER_NAME = "Test Plugin RegexErrorParser";
|
||||
|
@ -78,51 +86,24 @@ public class RegexErrorParserTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param name - name of the test.
|
||||
*/
|
||||
public RegexErrorParserTests(String name) {
|
||||
super(name);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
protected void beforeEach() throws Exception {
|
||||
fProject = ResourceHelper.createCDTProject(TEST_PROJECT_NAME);
|
||||
assertNotNull(fProject);
|
||||
errorList = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp(getName());
|
||||
fProject = null;
|
||||
|
||||
@AfterEach
|
||||
protected void resetUserDefinedErrorParsers() throws Exception {
|
||||
ErrorParserManager.setUserDefinedErrorParsers(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return - new TestSuite.
|
||||
*/
|
||||
public static TestSuite suite() {
|
||||
return new TestSuite(RegexErrorParserTests.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* main function of the class.
|
||||
*
|
||||
* @param args - arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(suite());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if error pattern can be added/deleted.
|
||||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRegexErrorParserAddDeletePattern() throws Exception {
|
||||
RegexErrorParser regexErrorParser = new RegexErrorParser();
|
||||
regexErrorParser.addPattern(
|
||||
|
@ -151,6 +132,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRegexErrorParserPatternOrder() throws Exception {
|
||||
final int ERR = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
|
||||
RegexErrorParser regexErrorParser = new RegexErrorParser();
|
||||
|
@ -186,7 +168,11 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRegexErrorParserParseOutput() throws Exception {
|
||||
// This test generates an expected error in the log
|
||||
setExpectedNumberOfLoggedNonOKStatusObjects(1);
|
||||
|
||||
RegexErrorParser regexErrorParser = new RegexErrorParser();
|
||||
regexErrorParser.addPattern(new RegexErrorPattern("(.*)#(.*)#(.*)#(.*)", "$1", "$2", "$3 $4", "var=$4",
|
||||
IMarkerGenerator.SEVERITY_ERROR_RESOURCE, true));
|
||||
|
@ -261,6 +247,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testCompatibility() throws Exception {
|
||||
final CCorePlugin cCorePlugin = CCorePlugin.getDefault();
|
||||
|
||||
|
@ -280,6 +267,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testExtension() throws Exception {
|
||||
// ErrorParserManager.getErrorParser
|
||||
{
|
||||
|
@ -322,6 +310,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testExtensionsSorting() throws Exception {
|
||||
{
|
||||
String[] ids = ErrorParserManager.getErrorParserExtensionIds();
|
||||
|
@ -339,14 +328,14 @@ public class RegexErrorParserTests extends TestCase {
|
|||
|
||||
// inside the same category sorted by names
|
||||
if (lastIsDeprecated == isDeprecated && lastIsTestPlugin == isTestPlugin) {
|
||||
assertTrue(message, lastName.compareTo(name) <= 0);
|
||||
assertTrue(lastName.compareTo(name) <= 0, message);
|
||||
}
|
||||
// deprecated follow non-deprecated (unless parsers from test plugin show up)
|
||||
if (lastIsTestPlugin == isTestPlugin) {
|
||||
assertFalse(message, lastIsDeprecated == true && isDeprecated == false);
|
||||
assertFalse(lastIsDeprecated == true && isDeprecated == false, message);
|
||||
}
|
||||
// error parsers from test plugin are the last
|
||||
assertFalse(message, lastIsTestPlugin == true && isTestPlugin == false);
|
||||
assertFalse(lastIsTestPlugin == true && isTestPlugin == false, message);
|
||||
|
||||
lastName = name;
|
||||
lastIsDeprecated = isDeprecated;
|
||||
|
@ -360,6 +349,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testAvailableErrorParsers() throws Exception {
|
||||
final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser";
|
||||
final String TESTING_NAME = "An error parser";
|
||||
|
@ -438,6 +428,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testUserDefinedErrorParsers() throws Exception {
|
||||
final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser";
|
||||
final String TESTING_NAME = "An error parser";
|
||||
|
@ -469,6 +460,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultErrorParserIds() throws Exception {
|
||||
final String[] availableParserIds = ErrorParserManager.getErrorParserAvailableIds();
|
||||
assertNotNull(availableParserIds);
|
||||
|
@ -507,6 +499,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testSerializeErrorParser() throws Exception {
|
||||
final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser";
|
||||
final String TESTING_NAME = "An error parser";
|
||||
|
@ -549,6 +542,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testSerializeRegexErrorParser() throws Exception {
|
||||
|
||||
final String TESTING_ID = "org.eclipse.cdt.core.test.regexerrorparser";
|
||||
|
@ -609,6 +603,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testSerializeRegexErrorParserSpecialCharacters() throws Exception {
|
||||
|
||||
final String TESTING_ID = "org.eclipse.cdt.core.test.regexerrorparser";
|
||||
|
@ -653,6 +648,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testSerializeDefaultErrorParserIds() throws Exception {
|
||||
final String[] testingDefaultErrorParserIds = { "org.eclipse.cdt.core.test.errorparser0",
|
||||
"org.eclipse.cdt.core.test.errorparser1", "org.eclipse.cdt.core.test.errorparser2", };
|
||||
|
@ -705,6 +701,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testGetErrorParserCopy() throws Exception {
|
||||
{
|
||||
IErrorParserNamed clone1 = ErrorParserManager.getErrorParserCopy(REGEX_ERRORPARSER_ID);
|
||||
|
@ -731,6 +728,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
*
|
||||
* @throws Exception...
|
||||
*/
|
||||
@Test
|
||||
public void testRegexErrorParserExternalLocation_bug301338() throws Exception {
|
||||
RegexErrorParser regexErrorParser = new RegexErrorParser();
|
||||
regexErrorParser.addPattern(
|
||||
|
|
|
@ -13,21 +13,19 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.internal.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.cdt.internal.core.PositionTracker;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.Region;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class PositionTrackerTests extends TestCase {
|
||||
public static Test suite() {
|
||||
return new TestSuite(PositionTrackerTests.class);
|
||||
}
|
||||
|
||||
public class PositionTrackerTests extends BaseTestCase5 {
|
||||
@Test
|
||||
public void testInitialFailures() {
|
||||
int[][] moves = {
|
||||
{ 46, -18, 95, -76, 98, -89, 10, -10, 85, -80, 16, 6, 5, -3, 22, -8, 29, -20, 86, -62, 34, -21, 63, -41,
|
||||
|
@ -41,6 +39,7 @@ public class PositionTrackerTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRotations() {
|
||||
int[][] moves = { { 0, 1, 2, 1, 4, 1, 6, 1, 8, 1, 10, 1, 12, 1, 14, 1, 16, 1, 18, 1, 20, 1, 22, 1, 24, 1 },
|
||||
{ 15, 1, 14, 1, 13, 1, 12, 1, 11, 1, 10, 1, 9, 1, 8, 1, 7, 1, 6, 1, 5, 1, 4, 1, 3, 1 },
|
||||
|
@ -51,34 +50,42 @@ public class PositionTrackerTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDepth4() {
|
||||
fullTest(5, 4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRandomDepth5() {
|
||||
randomTest(20, 5, 5, 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRandomDepth10() {
|
||||
randomTest(50, 10, 10, 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRandomDepth15() {
|
||||
randomTest(100, 15, 15, 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRandomDepth20() {
|
||||
randomTest(100, 15, 20, 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetireDepth2() {
|
||||
randomRetireTest(100, 10, 25, 2, 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetireDepth5() {
|
||||
randomRetireTest(100, 10, 10, 5, 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetireDepth10() {
|
||||
randomRetireTest(100, 10, 5, 10, 1000);
|
||||
}
|
||||
|
@ -242,6 +249,7 @@ public class PositionTrackerTests extends TestCase {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertion() {
|
||||
PositionTracker pt = new PositionTracker();
|
||||
pt.insert(1, 1);
|
||||
|
@ -266,6 +274,7 @@ public class PositionTrackerTests extends TestCase {
|
|||
doubleRangeCheck(pt, new Region(1, 0), new Region(2, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeletion() {
|
||||
PositionTracker pt = new PositionTracker();
|
||||
pt.delete(1, 1);
|
||||
|
@ -288,6 +297,7 @@ public class PositionTrackerTests extends TestCase {
|
|||
doubleRangeCheck(pt, new Region(2, 0), new Region(1, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplace() {
|
||||
PositionTracker pt = new PositionTracker();
|
||||
pt.delete(1, 1);
|
||||
|
|
|
@ -14,12 +14,14 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.internal.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
|
@ -30,28 +32,23 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class ResourceLookupTests extends BaseTestCase {
|
||||
public static Test suite() {
|
||||
return new TestSuite(ResourceLookupTests.class);
|
||||
}
|
||||
public class ResourceLookupTests extends BaseTestCase5 {
|
||||
|
||||
private IProject fProject;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@BeforeEach
|
||||
protected void beforeEach() throws Exception {
|
||||
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
fProject = root.getProject("reslookup_" + getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
fProject.delete(true, new NullProgressMonitor());
|
||||
super.tearDown();
|
||||
@AfterEach
|
||||
protected void afterEach() throws Exception {
|
||||
fProject.delete(true, true, new NullProgressMonitor());
|
||||
}
|
||||
|
||||
protected IFolder createFolder(IProject project, String filename) throws CoreException {
|
||||
|
@ -71,6 +68,7 @@ public class ResourceLookupTests extends BaseTestCase {
|
|||
return file;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNameLookup() throws CoreException {
|
||||
IProject[] prjs = new IProject[] { fProject };
|
||||
|
||||
|
@ -112,6 +110,7 @@ public class ResourceLookupTests extends BaseTestCase {
|
|||
assertEquals(3, files.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResourceDelta() throws CoreException {
|
||||
IProject[] prjs = new IProject[] { fProject };
|
||||
fProject.create(new NullProgressMonitor());
|
||||
|
@ -143,6 +142,7 @@ public class ResourceLookupTests extends BaseTestCase {
|
|||
assertEquals(1, files.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeref() throws CoreException {
|
||||
IProject[] prjs = new IProject[] { fProject };
|
||||
|
||||
|
@ -166,6 +166,7 @@ public class ResourceLookupTests extends BaseTestCase {
|
|||
assertEquals(3, files.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCollected() throws CoreException {
|
||||
IProject[] prjs = new IProject[] { fProject };
|
||||
|
||||
|
@ -189,6 +190,7 @@ public class ResourceLookupTests extends BaseTestCase {
|
|||
assertEquals(3, files.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindFilesByLocation() throws Exception {
|
||||
fProject.create(new NullProgressMonitor());
|
||||
fProject.open(new NullProgressMonitor());
|
||||
|
@ -215,6 +217,7 @@ public class ResourceLookupTests extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinkedResourceFiles() throws Exception {
|
||||
IProject[] prjs = new IProject[] { fProject };
|
||||
|
||||
|
|
|
@ -14,17 +14,18 @@
|
|||
|
||||
package org.eclipse.cdt.core.internal.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class StringBuilderTest extends TestCase {
|
||||
public static Test suite() {
|
||||
return new TestSuite(StringBuilderTest.class);
|
||||
}
|
||||
public class StringBuilderTest extends BaseTestCase5 {
|
||||
|
||||
@Test
|
||||
public void testSafe() {
|
||||
StringBuilder b1 = new StringBuilder();
|
||||
StringBuilder b2 = new StringBuilder();
|
||||
|
@ -35,6 +36,7 @@ public class StringBuilderTest extends TestCase {
|
|||
assertEquals("ab", b1.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug220158() {
|
||||
StringBuilder b1 = new StringBuilder();
|
||||
StringBuilder b2 = new StringBuilder();
|
||||
|
@ -44,6 +46,7 @@ public class StringBuilderTest extends TestCase {
|
|||
assertEquals("ab", b1.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringBuilderMethods() throws Exception {
|
||||
Class clazz = StringBuilder.class;
|
||||
Method method = clazz.getMethod("append", CharSequence.class);
|
||||
|
|
|
@ -13,6 +13,11 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.resources.tests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
@ -32,6 +37,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
|||
import org.eclipse.cdt.core.settings.model.WriteAccessException;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||
import org.eclipse.cdt.internal.core.resources.ResourceExclusion;
|
||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
|
@ -44,16 +50,15 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author crecoskie
|
||||
*
|
||||
*/
|
||||
public class RefreshScopeTests extends TestCase {
|
||||
public class RefreshScopeTests extends BaseTestCase5 {
|
||||
|
||||
private IProject fProject;
|
||||
private IProject fGeneralProject;
|
||||
|
@ -65,11 +70,8 @@ public class RefreshScopeTests extends TestCase {
|
|||
private IFolder fFolder6;
|
||||
private String config1, config2;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@BeforeEach
|
||||
protected void beforeEach() throws Exception {
|
||||
|
||||
// create project
|
||||
CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||
|
@ -141,14 +143,14 @@ public class RefreshScopeTests extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
@AfterEach
|
||||
protected void afterEach() throws Exception {
|
||||
fProject.delete(true, true, null);
|
||||
fGeneralProject.delete(true, true, null);
|
||||
BaseTestCase5.assertWorkspaceIsEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddDeleteResource() throws CoreException {
|
||||
|
||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||
|
@ -221,6 +223,7 @@ public class RefreshScopeTests extends TestCase {
|
|||
assertEquals(config2_resourcesAfterDelete.contains(fProject), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetResourcesToExclusionsMapRefresh() {
|
||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||
manager.clearAllData();
|
||||
|
@ -239,6 +242,7 @@ public class RefreshScopeTests extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddRemoveExclusion() {
|
||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||
manager.clearAllData();
|
||||
|
@ -272,6 +276,7 @@ public class RefreshScopeTests extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPersistAndLoad() {
|
||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||
manager.clearAllData();
|
||||
|
@ -418,6 +423,7 @@ public class RefreshScopeTests extends TestCase {
|
|||
manager.clearAllData();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResourceExclusion() {
|
||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||
manager.clearAllData();
|
||||
|
@ -534,6 +540,7 @@ public class RefreshScopeTests extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaults() {
|
||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||
manager.clearAllData();
|
||||
|
@ -602,6 +609,7 @@ public class RefreshScopeTests extends TestCase {
|
|||
return conf.getName();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyRefreshScopeCloseAndReopen() {
|
||||
|
||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||
|
@ -641,6 +649,7 @@ public class RefreshScopeTests extends TestCase {
|
|||
assertEquals(0, config_resources.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddEmptyConfiguration() {
|
||||
final String CFG_NAME = "empty_config";
|
||||
|
||||
|
@ -673,6 +682,7 @@ public class RefreshScopeTests extends TestCase {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullProjectDescription_bug387428() {
|
||||
final String CFG_NAME = "empty_config";
|
||||
|
||||
|
@ -688,8 +698,4 @@ public class RefreshScopeTests extends TestCase {
|
|||
assertEquals(true, empty_config_resources.contains(fGeneralProject));
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new TestSuite(RefreshScopeTests.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue