1
0
Fork 0
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:
Jonah Graham 2022-10-27 11:11:51 -04:00
parent 73d74a1db6
commit e1dea25b40
16 changed files with 334 additions and 339 deletions

View file

@ -51,4 +51,6 @@ Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-RequiredExecutionEnvironment: JavaSE-17
Automatic-Module-Name: org.eclipse.cdt.core.tests Automatic-Module-Name: org.eclipse.cdt.core.tests
Bundle-Localization: plugin 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"

View file

@ -13,6 +13,11 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.envvar; 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.io.ByteArrayInputStream;
import java.util.Arrays; 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.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.testplugin.ResourceHelper; 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.internal.core.envvar.EnvironmentVariableManager;
import org.eclipse.cdt.utils.envvar.IEnvironmentChangeEvent; import org.eclipse.cdt.utils.envvar.IEnvironmentChangeEvent;
import org.eclipse.cdt.utils.envvar.IEnvironmentChangeListener; 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.IJobManager;
import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.junit.jupiter.api.Test;
import junit.framework.Test; public class IEnvironmentVariableManagerTests extends BaseTestCase5 {
import junit.framework.TestCase;
import junit.framework.TestSuite;
public class IEnvironmentVariableManagerTests extends TestCase {
/** /**
* Mock listener to listen to environment variable change events. * 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 * Create a project with 2 configurations. Set an environment variable on one of
* the configurations. Close and reopen the project. Check persistence * the configurations. Close and reopen the project. Check persistence
* @throws Exception * @throws Exception
*/ */
@Test
public void testSimpleVar() throws Exception { public void testSimpleVar() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject"); 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. * Also tests that an an external change to the settings file is correctly picked up.
* @throws Exception * @throws Exception
*/ */
@Test
public void testOldStyleLoad() throws Exception { public void testOldStyleLoad() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProjectOldStyleLoad"); 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. * Tests we can load an old-style preferences while an incompatible scheduling rule is held.
* @throws Exception * @throws Exception
*/ */
@Test
public void testOldStyleLoadConflictingSchedulingRule() throws Exception { public void testOldStyleLoadConflictingSchedulingRule() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("incompatibleSchedRule"); 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 * Test that an ovewrite of new style preferences is loaded correctly
* @throws Exception * @throws Exception
*/ */
@Test
public void testNewStyleOverwrite() throws Exception { public void testNewStyleOverwrite() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProjectNewStyleLoad"); 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)); assertEquals(var2, envManager.getVariable(var2.getName(), prjDesc.getConfigurationById(id2), true));
} }
@Test
public void testNoChangeToOneVariable() throws Exception { public void testNoChangeToOneVariable() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject"); final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
@ -344,6 +337,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
/** /**
* tests the get / set append persisting * tests the get / set append persisting
*/ */
@Test
public void testGetSetAppend() throws Exception { public void testGetSetAppend() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject"); final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
@ -387,6 +381,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
/** /**
* Tests file system change of the settings file * Tests file system change of the settings file
*/ */
@Test
public void testSettingsOverwrite() throws Exception { public void testSettingsOverwrite() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject"); 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 * Tests file system change of the settings file without recreating the project description
*/ */
@Test
public void testSettingsOverwriteBug295436() throws Exception { public void testSettingsOverwriteBug295436() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject"); 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 * Test that on deleting and recreating the project variables haven't persisted
* @throws Exception * @throws Exception
*/ */
@Test
public void testBrokenCaching() throws Exception { public void testBrokenCaching() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject"); 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 * The model shouldn't cache incorrect variables / values in the project description
* @throws Exception * @throws Exception
*/ */
@Test
public void testBug265282() throws Exception { public void testBug265282() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject"); final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
@ -625,6 +623,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
* *
* @throws Exception * @throws Exception
*/ */
@Test
public void testBug284843() throws Exception { public void testBug284843() throws Exception {
final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject"); final IProject project = ResourceHelper.createCDTProjectWithConfig("envProject");
ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project); ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(project);
@ -678,6 +677,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
* *
* @throws Exception * @throws Exception
*/ */
@Test
public void testEnvironmentChangeListener() throws Exception { public void testEnvironmentChangeListener() throws Exception {
// Register environment event listener // Register environment event listener
MockEnvironmentListener envListener = new MockEnvironmentListener(); MockEnvironmentListener envListener = new MockEnvironmentListener();

View file

@ -13,17 +13,19 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.internal.efsextension.tests; 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.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
import org.eclipse.cdt.utils.EFSExtensionManager; import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.junit.jupiter.api.Test;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/** /**
* Tests the EFSExtensionManager and EFSExtensionProvider classes, as well as the EFSExtensionProvider extension point. * Tests the EFSExtensionManager and EFSExtensionProvider classes, as well as the EFSExtensionProvider extension point.
@ -31,7 +33,8 @@ import junit.framework.TestSuite;
* @author crecoskie * @author crecoskie
* *
*/ */
public class EFSExtensionTests extends TestCase { public class EFSExtensionTests extends BaseTestCase5 {
@Test
public void testReplaceInRSEURI() { public void testReplaceInRSEURI() {
URI originalURI = null; URI originalURI = null;
URI expected = null; URI expected = null;
@ -49,6 +52,7 @@ public class EFSExtensionTests extends TestCase {
assertEquals(expected, uri); assertEquals(expected, uri);
} }
@Test
public void testReplaceInUNIXURI() { public void testReplaceInUNIXURI() {
URI originalURI = null; URI originalURI = null;
URI expected = null; URI expected = null;
@ -66,6 +70,7 @@ public class EFSExtensionTests extends TestCase {
assertEquals(expected, uri); assertEquals(expected, uri);
} }
@Test
public void testReplaceInWindowsURI() { public void testReplaceInWindowsURI() {
URI originalURI = null; URI originalURI = null;
URI expected = null; URI expected = null;
@ -83,6 +88,7 @@ public class EFSExtensionTests extends TestCase {
assertEquals(expected, uri); assertEquals(expected, uri);
} }
@Test
public void testReplaceInMadeUpURI() { public void testReplaceInMadeUpURI() {
URI originalURI = null; URI originalURI = null;
URI expected = null; URI expected = null;
@ -100,6 +106,7 @@ public class EFSExtensionTests extends TestCase {
assertEquals(expected, uri); assertEquals(expected, uri);
} }
@Test
public void testReplaceWithWindowsPathNoLeadingSlash() { public void testReplaceWithWindowsPathNoLeadingSlash() {
URI originalURI = null; URI originalURI = null;
URI expected = null; URI expected = null;
@ -123,6 +130,7 @@ public class EFSExtensionTests extends TestCase {
assertEquals(expected, uri); assertEquals(expected, uri);
} }
@Test
public void testReplaceURIWithAuthority() { public void testReplaceURIWithAuthority() {
URI originalURI = null; URI originalURI = null;
URI expected = null; URI expected = null;
@ -141,6 +149,7 @@ public class EFSExtensionTests extends TestCase {
assertEquals(expected, uri); assertEquals(expected, uri);
} }
@Test
public void testReplaceURIWithAuthority2() { public void testReplaceURIWithAuthority2() {
URI originalURI = null; URI originalURI = null;
URI expected = null; URI expected = null;
@ -159,6 +168,7 @@ public class EFSExtensionTests extends TestCase {
assertEquals(expected, uri); assertEquals(expected, uri);
} }
@Test
public void testAppendinRSEURI() { public void testAppendinRSEURI() {
URI originalURI = null; URI originalURI = null;
URI expected = null; URI expected = null;
@ -174,6 +184,7 @@ public class EFSExtensionTests extends TestCase {
assertEquals(expected, uri); assertEquals(expected, uri);
} }
@Test
public void testAppendToUNIXURI() { public void testAppendToUNIXURI() {
URI originalURI = null; URI originalURI = null;
URI expected = null; URI expected = null;
@ -189,6 +200,7 @@ public class EFSExtensionTests extends TestCase {
assertEquals(expected, uri); assertEquals(expected, uri);
} }
@Test
public void testAppendToWindowsURI() { public void testAppendToWindowsURI() {
URI originalURI = null; URI originalURI = null;
URI expected = null; URI expected = null;
@ -204,6 +216,7 @@ public class EFSExtensionTests extends TestCase {
assertEquals(expected, uri); assertEquals(expected, uri);
} }
@Test
public void testGetLinkedURI() { public void testGetLinkedURI() {
URI originalURI = null; URI originalURI = null;
try { try {
@ -217,6 +230,7 @@ public class EFSExtensionTests extends TestCase {
assertEquals(originalURI, uri); assertEquals(originalURI, uri);
} }
@Test
public void testGetMappedPath() { public void testGetMappedPath() {
URI originalURI = null; URI originalURI = null;
try { try {
@ -234,6 +248,7 @@ public class EFSExtensionTests extends TestCase {
} }
} }
@Test
public void testGetPathFromURI() { public void testGetPathFromURI() {
URI originalURI = null; URI originalURI = null;
try { try {
@ -251,6 +266,7 @@ public class EFSExtensionTests extends TestCase {
} }
} }
@Test
public void testExtension() { public void testExtension() {
URI originalURI = null; URI originalURI = null;
try { try {
@ -262,8 +278,4 @@ public class EFSExtensionTests extends TestCase {
assertTrue(EFSExtensionManager.getDefault().isVirtual(originalURI)); assertTrue(EFSExtensionManager.getDefault().isVirtual(originalURI));
} }
public static Test suite() {
TestSuite suite = new TestSuite(EFSExtensionTests.class);
return suite;
}
} }

View file

@ -14,6 +14,10 @@
package org.eclipse.cdt.core.internal.errorparsers.tests; 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.ByteArrayInputStream;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; 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.errorparsers.ErrorPattern;
import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.cdt.core.testplugin.ResourceHelper; 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.internal.registry.ExtensionRegistry;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; 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.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.junit.jupiter.api.BeforeEach;
import junit.framework.Assert; import org.junit.jupiter.api.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/** /**
* The test case includes a few tests checking that {@link AbstractErrorParser}/{@link ErrorPattern} * 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. * 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 static final String MAKE_ERRORPARSER_ID = "org.eclipse.cdt.core.CWDLocator";
private String mockErrorParserId = null; private String mockErrorParserId = null;
@ -80,47 +83,16 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
} }
} }
/** @BeforeEach
* Constructor. protected void beforeEach() throws Exception {
* @param name - name of the test.
*/
public ErrorParserEfsFileMatchingTest(String name) {
super(name);
}
@Override
protected void setUp() throws Exception {
if (fProject == null) { if (fProject == null) {
fProject = ResourceHelper.createCDTProject(testName); fProject = ResourceHelper.createCDTProject(testName);
Assert.assertNotNull(fProject); assertNotNull(fProject);
mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class); mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class);
} }
errorList = new ArrayList<>(); 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. * Adds Error Parser extension to the global repository.
* Note that this function will "pollute" the working environment and * 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()), boolean added = Platform.getExtensionRegistry().addContribution(new ByteArrayInputStream(ext.getBytes()),
contributor, false, shortId, null, contributor, false, shortId, null,
((ExtensionRegistry) Platform.getExtensionRegistry()).getTemporaryUserToken()); ((ExtensionRegistry) Platform.getExtensionRegistry()).getTemporaryUserToken());
assertTrue("failed to add extension", added); assertTrue(added, "failed to add extension");
String fullId = "org.eclipse.cdt.core.tests." + shortId; String fullId = "org.eclipse.cdt.core.tests." + shortId;
IErrorParser[] errorParser = CCorePlugin.getDefault().getErrorParser(fullId); IErrorParser[] errorParser = CCorePlugin.getDefault().getErrorParser(fullId);
assertTrue(errorParser.length > 0); assertTrue(errorParser.length > 0);
@ -210,6 +182,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testSingle() throws Exception { public void testSingle() throws Exception {
ResourceHelper.createEfsFile(fProject, "testSingle.c", "null:/efsTestSingle.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testEfsVsRegular() throws Exception { public void testEfsVsRegular() throws Exception {
ResourceHelper.createFile(fProject, "testEfsVsRegular.c"); ResourceHelper.createFile(fProject, "testEfsVsRegular.c");
ResourceHelper.createEfsFile(fProject, "efsTestEfsVsRegular.c", "null:/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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testFullPath() throws Exception { public void testFullPath() throws Exception {
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder"); ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
ResourceHelper.createEfsFile(fProject, "Folder/testFullPath.c", "null:/EfsFolder/efsTestFullPath.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testInNonEfsFolder() throws Exception { public void testInNonEfsFolder() throws Exception {
ResourceHelper.createFolder(fProject, "NonEfsFolder"); ResourceHelper.createFolder(fProject, "NonEfsFolder");
ResourceHelper.createEfsFile(fProject, "NonEfsFolder/testInNonEfsFolder.c", 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testInFolder() throws Exception { public void testInFolder() throws Exception {
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder"); ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
ResourceHelper.createEfsFile(fProject, "Folder/testInFolder.c", "null:/EfsFolder/efsTestInFolder.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDuplicateInRoot() throws Exception { public void testDuplicateInRoot() throws Exception {
ResourceHelper.createEfsFile(fProject, "testDuplicateInRoot.c", "null:/testDuplicateInRoot.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathFromProjectRoot() throws Exception { public void testRelativePathFromProjectRoot() throws Exception {
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder"); ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
ResourceHelper.createEfsFile(fProject, "Folder/testRelativePathFromProjectRoot.c", 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathFromSubfolder() throws Exception { public void testRelativePathFromSubfolder() throws Exception {
ResourceHelper.createEfsFolder(fProject, "Subfolder", "null:/Subfolder"); ResourceHelper.createEfsFolder(fProject, "Subfolder", "null:/Subfolder");
ResourceHelper.createEfsFolder(fProject, "Subfolder/Folder", "null:/Subfolder/Folder"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathNotMatchingFolder() throws Exception { public void testRelativePathNotMatchingFolder() throws Exception {
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder"); ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
ResourceHelper.createEfsFile(fProject, "Folder/testRelativePathNotMatchingFolder.c", 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathDuplicate() throws Exception { public void testRelativePathDuplicate() throws Exception {
ResourceHelper.createEfsFolder(fProject, "SubfolderA", "null:/SubfolderA"); ResourceHelper.createEfsFolder(fProject, "SubfolderA", "null:/SubfolderA");
ResourceHelper.createEfsFolder(fProject, "SubfolderA/Folder", "null:/SubfolderA/Folder"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathUpSubfolder() throws Exception { public void testRelativePathUpSubfolder() throws Exception {
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder"); ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
ResourceHelper.createEfsFile(fProject, "Folder/testRelativePathUpSubfolder.c", 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathDotFromSubfolder() throws Exception { public void testRelativePathDotFromSubfolder() throws Exception {
ResourceHelper.createEfsFolder(fProject, "Subfolder", "null:/Subfolder"); ResourceHelper.createEfsFolder(fProject, "Subfolder", "null:/Subfolder");
ResourceHelper.createEfsFolder(fProject, "Subfolder/Folder", "null:/Subfolder/Folder"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testBuildDir() throws Exception { public void testBuildDir() throws Exception {
ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder"); ResourceHelper.createEfsFolder(fProject, "Folder", "null:/Folder");
ResourceHelper.createEfsFile(fProject, "Folder/testBuildDir.c", "null:/Folder/testBuildDir.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testEfsProject() throws Exception { public void testEfsProject() throws Exception {
IFile efsSmokeTest = ResourceHelper.createEfsFile(fProject, "efsSmokeTest.c", "mem:/efsSmokeTest.c"); 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")); IProject efsProject = ResourceHelper.createCDTProject("EfsProject", new URI("mem:/EfsProject"));
ResourceHelper.createFolder(efsProject, "Folder"); ResourceHelper.createFolder(efsProject, "Folder");
@ -476,6 +462,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testEfsProjectBuildDirURI() throws Exception { public void testEfsProjectBuildDirURI() throws Exception {
String fileName = "testEfsProjectBuildDirURI.c"; String fileName = "testEfsProjectBuildDirURI.c";
@ -499,6 +486,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testEfsProjectPushPopDirectory() throws Exception { public void testEfsProjectPushPopDirectory() throws Exception {
String fileName = "testEfsProjectPushPopDirectory.c"; String fileName = "testEfsProjectPushPopDirectory.c";

View file

@ -15,6 +15,10 @@
package org.eclipse.cdt.core.internal.errorparsers.tests; 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.ByteArrayInputStream;
import java.util.ArrayList; 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.errorparsers.ErrorPattern;
import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.cdt.core.testplugin.ResourceHelper; 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.cdt.internal.core.Cygwin;
import org.eclipse.core.internal.registry.ExtensionRegistry; import org.eclipse.core.internal.registry.ExtensionRegistry;
import org.eclipse.core.resources.IFile; 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.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.junit.jupiter.api.BeforeEach;
import junit.framework.Assert; import org.junit.jupiter.api.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/** /**
* The test case includes a few tests checking that {@link AbstractErrorParser}/{@link ErrorPattern} * The test case includes a few tests checking that {@link AbstractErrorParser}/{@link ErrorPattern}
* properly locate and resolve filenames found in build output. * 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 static final String CWD_LOCATOR_ID = "org.eclipse.cdt.core.CWDLocator";
private String mockErrorParserId = null; private String mockErrorParserId = null;
@ -83,47 +86,14 @@ public class ErrorParserFileMatchingTest extends TestCase {
} }
} }
/** @BeforeEach
* Constructor. protected void beforeEach() throws Exception {
* @param name - name of the test. fProject = ResourceHelper.createCDTProject(testName);
*/ assertNotNull(fProject);
public ErrorParserFileMatchingTest(String name) { mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class);
super(name);
}
@Override
protected void setUp() throws Exception {
if (fProject == null) {
fProject = ResourceHelper.createCDTProject(testName);
Assert.assertNotNull(fProject);
mockErrorParserId = addErrorParserExtension("MockErrorParser", MockErrorParser.class);
}
errorList = new ArrayList<>(); 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. * Adds Error Parser extension to the global repository.
* Note that this function will "pollute" the working environment and * 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()), boolean added = Platform.getExtensionRegistry().addContribution(new ByteArrayInputStream(ext.getBytes()),
contributor, false, shortId, null, contributor, false, shortId, null,
((ExtensionRegistry) Platform.getExtensionRegistry()).getTemporaryUserToken()); ((ExtensionRegistry) Platform.getExtensionRegistry()).getTemporaryUserToken());
assertTrue("failed to add extension", added); assertTrue(added, "failed to add extension");
String fullId = "org.eclipse.cdt.core.tests." + shortId; String fullId = "org.eclipse.cdt.core.tests." + shortId;
IErrorParser[] errorParser = CCorePlugin.getDefault().getErrorParser(fullId); IErrorParser[] errorParser = CCorePlugin.getDefault().getErrorParser(fullId);
assertTrue(errorParser.length > 0); assertTrue(errorParser.length > 0);
@ -194,6 +164,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testSingle() throws Exception { public void testSingle() throws Exception {
ResourceHelper.createFile(fProject, "testSingle.c"); ResourceHelper.createFile(fProject, "testSingle.c");
@ -210,6 +181,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks that no false positive for missing file generated. * Checks that no false positive for missing file generated.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testMissing() throws Exception { public void testMissing() throws Exception {
parseOutput("testMissing.c:1:error"); parseOutput("testMissing.c:1:error");
@ -227,6 +199,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if duplicate files give ambiguous match. * Checks if duplicate files give ambiguous match.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDuplicate() throws Exception { public void testDuplicate() throws Exception {
ResourceHelper.createFolder(fProject, "FolderA"); ResourceHelper.createFolder(fProject, "FolderA");
ResourceHelper.createFile(fProject, "FolderA/testDuplicate.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testInFolder() throws Exception { public void testInFolder() throws Exception {
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, "Folder/testInFolder.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDuplicateInRoot() throws Exception { public void testDuplicateInRoot() throws Exception {
ResourceHelper.createFile(fProject, "testDuplicateInRoot.c"); ResourceHelper.createFile(fProject, "testDuplicateInRoot.c");
@ -284,6 +259,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testLinkedFile() throws Exception { public void testLinkedFile() throws Exception {
ResourceHelper.createWorkspaceFolder("OutsideFolder"); ResourceHelper.createWorkspaceFolder("OutsideFolder");
IPath realFile = ResourceHelper.createWorkspaceFile("OutsideFolder/testLinkedFile.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testLinkedFileWithDifferentName() throws Exception { public void testLinkedFileWithDifferentName() throws Exception {
ResourceHelper.createWorkspaceFolder("OutsideFolder"); ResourceHelper.createWorkspaceFolder("OutsideFolder");
IPath realFile = ResourceHelper.createWorkspaceFile("OutsideFolder/RealFileWithDifferentName.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDuplicateLinkedFile() throws Exception { public void testDuplicateLinkedFile() throws Exception {
ResourceHelper.createWorkspaceFolder("OutsideFolderA"); ResourceHelper.createWorkspaceFolder("OutsideFolderA");
ResourceHelper.createWorkspaceFolder("OutsideFolderB"); ResourceHelper.createWorkspaceFolder("OutsideFolderB");
@ -346,6 +324,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDuplicateLinkedFileDifferentName() throws Exception { public void testDuplicateLinkedFileDifferentName() throws Exception {
ResourceHelper.createWorkspaceFolder("OutsideFolderA"); ResourceHelper.createWorkspaceFolder("OutsideFolderA");
ResourceHelper.createWorkspaceFolder("OutsideFolderB"); ResourceHelper.createWorkspaceFolder("OutsideFolderB");
@ -370,6 +349,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testInLinkedFolder() throws Exception { public void testInLinkedFolder() throws Exception {
IPath outsideFolder = ResourceHelper.createWorkspaceFolder("OutsideFolder"); IPath outsideFolder = ResourceHelper.createWorkspaceFolder("OutsideFolder");
ResourceHelper.createWorkspaceFile("OutsideFolder/testInLinkedFolder.c"); ResourceHelper.createWorkspaceFile("OutsideFolder/testInLinkedFolder.c");
@ -387,6 +367,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDuplicateInLinkedFolder() throws Exception { public void testDuplicateInLinkedFolder() throws Exception {
IPath folderA = ResourceHelper.createWorkspaceFolder("OutsideFolderA"); IPath folderA = ResourceHelper.createWorkspaceFolder("OutsideFolderA");
ResourceHelper.createWorkspaceFile("OutsideFolderA/testDuplicateInLinkedFolder.c"); ResourceHelper.createWorkspaceFile("OutsideFolderA/testDuplicateInLinkedFolder.c");
@ -410,6 +391,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testLinkedFolderInAnotherProject() throws Exception { public void testLinkedFolderInAnotherProject() throws Exception {
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, "Folder/testLinkedFolderInAnotherProject.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testSymbolicLink() throws Exception { public void testSymbolicLink() throws Exception {
// do not test on systems where symbolic links are not supported // do not test on systems where symbolic links are not supported
if (!ResourceHelper.isSymbolicLinkSupported()) if (!ResourceHelper.isSymbolicLinkSupported())
@ -465,6 +448,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDuplicateSymbolicLink() throws Exception { public void testDuplicateSymbolicLink() throws Exception {
// do not test on systems where symbolic links are not supported // do not test on systems where symbolic links are not supported
if (!ResourceHelper.isSymbolicLinkSupported()) if (!ResourceHelper.isSymbolicLinkSupported())
@ -493,6 +477,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testFolderSymbolicLink() throws Exception { public void testFolderSymbolicLink() throws Exception {
// do not test on systems where symbolic links are not supported // do not test on systems where symbolic links are not supported
if (!ResourceHelper.isSymbolicLinkSupported()) if (!ResourceHelper.isSymbolicLinkSupported())
@ -516,6 +501,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDuplicateFolderSymbolicLink() throws Exception { public void testDuplicateFolderSymbolicLink() throws Exception {
// do not test on systems where symbolic links are not supported // do not test on systems where symbolic links are not supported
if (!ResourceHelper.isSymbolicLinkSupported()) if (!ResourceHelper.isSymbolicLinkSupported())
@ -541,6 +527,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testAbsolutePathSingle() throws Exception { public void testAbsolutePathSingle() throws Exception {
ResourceHelper.createFile(fProject, "testAbsolutePathSingle.c"); ResourceHelper.createFile(fProject, "testAbsolutePathSingle.c");
String fullName = fProject.getLocation().append("testAbsolutePathSingle.c").toOSString(); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testAbsolutePathInOtherProject() throws Exception { public void testAbsolutePathInOtherProject() throws Exception {
IProject anotherProject = ResourceHelper.createCDTProject("ProjectAbsolutePathInOtherProject"); IProject anotherProject = ResourceHelper.createCDTProject("ProjectAbsolutePathInOtherProject");
ResourceHelper.createFile(anotherProject, "testAbsolutePathInOtherProject.c"); ResourceHelper.createFile(anotherProject, "testAbsolutePathInOtherProject.c");
@ -577,6 +565,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testAbsolutePathOutsideWorkspace() throws Exception { public void testAbsolutePathOutsideWorkspace() throws Exception {
ResourceHelper.createWorkspaceFolder("OutsideFolder"); ResourceHelper.createWorkspaceFolder("OutsideFolder");
@ -599,6 +588,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathFromProjectRoot() throws Exception { public void testRelativePathFromProjectRoot() throws Exception {
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, "Folder/testRelativePathFromProjectRoot.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathFromSubfolder() throws Exception { public void testRelativePathFromSubfolder() throws Exception {
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFolder(fProject, "Folder/SubFolder"); ResourceHelper.createFolder(fProject, "Folder/SubFolder");
@ -636,6 +627,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathNotMatchingFolder() throws Exception { public void testRelativePathNotMatchingFolder() throws Exception {
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, "Folder/testRelativePathNotMatchingFolder.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathDuplicate() throws Exception { public void testRelativePathDuplicate() throws Exception {
ResourceHelper.createFolder(fProject, "SubfolderA"); ResourceHelper.createFolder(fProject, "SubfolderA");
ResourceHelper.createFolder(fProject, "SubfolderA/Folder"); ResourceHelper.createFolder(fProject, "SubfolderA/Folder");
@ -678,6 +671,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathUp() throws Exception { public void testRelativePathUp() throws Exception {
ResourceHelper.createFile(fProject, "testRelativePathUp.c"); ResourceHelper.createFile(fProject, "testRelativePathUp.c");
@ -694,6 +688,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathUpSubfolderBug262988() throws Exception { public void testRelativePathUpSubfolderBug262988() throws Exception {
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, "Folder/testRelativePathUpSubfolder.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathUpOtherProject() throws Exception { public void testRelativePathUpOtherProject() throws Exception {
IProject anotherProject = ResourceHelper.createCDTProject("AnotherProject"); IProject anotherProject = ResourceHelper.createCDTProject("AnotherProject");
ResourceHelper.createFile(anotherProject, "testRelativePathUpOtherProject.c"); ResourceHelper.createFile(anotherProject, "testRelativePathUpOtherProject.c");
@ -728,6 +724,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathUpDuplicate() throws Exception { public void testRelativePathUpDuplicate() throws Exception {
ResourceHelper.createFolder(fProject, "FolderA/SubFolder"); ResourceHelper.createFolder(fProject, "FolderA/SubFolder");
ResourceHelper.createFolder(fProject, "FolderB/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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathDotFromProjectRoot() throws Exception { public void testRelativePathDotFromProjectRoot() throws Exception {
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, "Folder/testRelativePathDotFromProjectRoot.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathDotFromSubfolder() throws Exception { public void testRelativePathDotFromSubfolder() throws Exception {
ResourceHelper.createFolder(fProject, "Subfolder"); ResourceHelper.createFolder(fProject, "Subfolder");
ResourceHelper.createFolder(fProject, "Subfolder/Folder"); ResourceHelper.createFolder(fProject, "Subfolder/Folder");
@ -786,6 +785,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathDotNotMatchingFolder() throws Exception { public void testRelativePathDotNotMatchingFolder() throws Exception {
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, "Subfolder/Folder/testRelativePathDotNotMatchingFolder.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRelativePathDotDuplicate() throws Exception { public void testRelativePathDotDuplicate() throws Exception {
ResourceHelper.createFolder(fProject, "SubfolderA"); ResourceHelper.createFolder(fProject, "SubfolderA");
ResourceHelper.createFolder(fProject, "SubfolderA/Folder"); ResourceHelper.createFolder(fProject, "SubfolderA/Folder");
@ -830,6 +831,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testUppercase1() throws Exception { public void testUppercase1() throws Exception {
if (!Platform.getOS().equals(Platform.OS_WIN32)) { if (!Platform.getOS().equals(Platform.OS_WIN32)) {
// This test is valid on Windows platform only // 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testUppercase2InSubFolder() throws Exception { public void testUppercase2InSubFolder() throws Exception {
// Note that old MSDOS can handle only 8 characters in file name // Note that old MSDOS can handle only 8 characters in file name
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -869,6 +872,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testUppercase3ResolveCase() throws Exception { public void testUppercase3ResolveCase() throws Exception {
// Note that old MSDOS can handle only 8 characters in file name // Note that old MSDOS can handle only 8 characters in file name
ResourceHelper.createFolder(fProject, "FolderA"); ResourceHelper.createFolder(fProject, "FolderA");
@ -889,6 +893,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testUppercase4Duplicate() throws Exception { public void testUppercase4Duplicate() throws Exception {
// Note that old MSDOS can handle only 8 characters in file name // Note that old MSDOS can handle only 8 characters in file name
ResourceHelper.createFolder(fProject, "FolderA"); ResourceHelper.createFolder(fProject, "FolderA");
@ -911,6 +916,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testCygwinCygdrive() throws Exception { public void testCygwinCygdrive() throws Exception {
String fileName = "testCygwinCygdrive.c"; String fileName = "testCygwinCygdrive.c";
String windowsFileName = fProject.getLocation().append(fileName).toOSString(); String windowsFileName = fProject.getLocation().append(fileName).toOSString();
@ -921,7 +927,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
// Skip the test if Cygwin is not available. // Skip the test if Cygwin is not available.
return; return;
} }
assertTrue("cygwinFileName=[" + cygwinFileName + "]", cygwinFileName.startsWith("/cygdrive/")); assertTrue(cygwinFileName.startsWith("/cygdrive/"), "cygwinFileName=[" + cygwinFileName + "]");
ResourceHelper.createFile(fProject, fileName); ResourceHelper.createFile(fProject, fileName);
@ -938,6 +944,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testCygwinUsrUnclude() throws Exception { public void testCygwinUsrUnclude() throws Exception {
String cygwinFolder = "/usr/include/"; String cygwinFolder = "/usr/include/";
String fileName = "stdio.h"; String fileName = "stdio.h";
@ -950,11 +957,11 @@ public class ErrorParserFileMatchingTest extends TestCase {
return; return;
} }
assertTrue("usrIncludeWindowsPath=[" + usrIncludeWindowsPath + "]", assertTrue(usrIncludeWindowsPath.charAt(1) == IPath.DEVICE_SEPARATOR,
usrIncludeWindowsPath.charAt(1) == IPath.DEVICE_SEPARATOR); "usrIncludeWindowsPath=[" + usrIncludeWindowsPath + "]");
java.io.File file = new java.io.File(usrIncludeWindowsPath + "\\" + fileName); 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); ResourceHelper.createLinkedFolder(fProject, "include", usrIncludeWindowsPath);
@ -971,6 +978,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testCygwinAnotherProject() throws Exception { public void testCygwinAnotherProject() throws Exception {
String fileName = "testCygwinAnotherProject.c"; String fileName = "testCygwinAnotherProject.c";
IProject anotherProject = ResourceHelper.createCDTProject("AnotherProject"); IProject anotherProject = ResourceHelper.createCDTProject("AnotherProject");
@ -983,7 +991,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
// Skip the test if Cygwin is not available. // Skip the test if Cygwin is not available.
return; return;
} }
assertTrue("cygwinFileName=[" + cygwinFileName + "]", cygwinFileName.startsWith("/cygdrive/")); assertTrue(cygwinFileName.startsWith("/cygdrive/"), "cygwinFileName=[" + cygwinFileName + "]");
ResourceHelper.createFile(anotherProject, fileName); ResourceHelper.createFile(anotherProject, fileName);
@ -1000,6 +1008,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testCustomProjectLocation() throws Exception { public void testCustomProjectLocation() throws Exception {
ResourceHelper.createWorkspaceFolder("Custom"); ResourceHelper.createWorkspaceFolder("Custom");
ResourceHelper.createWorkspaceFolder("Custom/ProjectLocation"); ResourceHelper.createWorkspaceFolder("Custom/ProjectLocation");
@ -1022,6 +1031,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testCygwinAndMakeErrorParserBug270772() throws Exception { public void testCygwinAndMakeErrorParserBug270772() throws Exception {
String fileName = "testCygwinAndMakeErrorParser.c"; String fileName = "testCygwinAndMakeErrorParser.c";
String windowsFileName = fProject.getLocation().append(fileName).toOSString(); String windowsFileName = fProject.getLocation().append(fileName).toOSString();
@ -1032,7 +1042,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
// Skip the test if Cygwin is not available. // Skip the test if Cygwin is not available.
return; return;
} }
assertTrue("cygwinFileName=[" + cygwinFileName + "]", cygwinFileName.startsWith("/cygdrive/")); assertTrue(cygwinFileName.startsWith("/cygdrive/"), "cygwinFileName=[" + cygwinFileName + "]");
ResourceHelper.createFile(fProject, fileName); ResourceHelper.createFile(fProject, fileName);
@ -1052,6 +1062,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testInNestedProject() throws Exception { public void testInNestedProject() throws Exception {
ResourceHelper.createFolder(fProject, "NestedProjectFolder"); ResourceHelper.createFolder(fProject, "NestedProjectFolder");
IProject nestedProject = ResourceHelper.createCDTProject("NestedProject", IProject nestedProject = ResourceHelper.createCDTProject("NestedProject",
@ -1086,6 +1097,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* Checks if a file from error output can be found. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testBuildDir() throws Exception { public void testBuildDir() throws Exception {
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFile(fProject, "Folder/testBuildDir.c"); 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. * Checks if a file from error output can be found.
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testBuildDirVsProjectRoot() throws Exception { public void testBuildDirVsProjectRoot() throws Exception {
ResourceHelper.createFile(fProject, "testBuildDirVsProjectRoot.c"); ResourceHelper.createFile(fProject, "testBuildDirVsProjectRoot.c");
ResourceHelper.createFolder(fProject, "BuildDir"); ResourceHelper.createFolder(fProject, "BuildDir");
@ -1126,6 +1139,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testAbsoluteFileVsLink() throws Exception { public void testAbsoluteFileVsLink() throws Exception {
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
IFile file = ResourceHelper.createFile(fProject, "Folder/testAbsoluteFileVsLink.c"); IFile file = ResourceHelper.createFile(fProject, "Folder/testAbsoluteFileVsLink.c");
@ -1146,6 +1160,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testPushDirectory() throws Exception { public void testPushDirectory() throws Exception {
String fileName = "testPushDirectory.c"; String fileName = "testPushDirectory.c";
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -1170,6 +1185,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testPushDirectorySingleQuote() throws Exception { public void testPushDirectorySingleQuote() throws Exception {
String fileName = "testPushDirectory.c"; String fileName = "testPushDirectory.c";
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -1193,6 +1209,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testPushAbsoluteDirectory() throws Exception { public void testPushAbsoluteDirectory() throws Exception {
String fileName = "testPushAbsoluteDirectory.c"; String fileName = "testPushAbsoluteDirectory.c";
IFolder folder = ResourceHelper.createFolder(fProject, "Folder"); IFolder folder = ResourceHelper.createFolder(fProject, "Folder");
@ -1200,7 +1217,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
ResourceHelper.createFile(fProject, "Folder/" + fileName); ResourceHelper.createFile(fProject, "Folder/" + fileName);
IPath absoluteDir = folder.getLocation(); IPath absoluteDir = folder.getLocation();
Assert.assertTrue(absoluteDir.isAbsolute()); assertTrue(absoluteDir.isAbsolute());
String lines = "make[0]: Entering directory `" + absoluteDir + "'\n" + fileName + ":1:error\n"; String lines = "make[0]: Entering directory `" + absoluteDir + "'\n" + fileName + ":1:error\n";
@ -1219,6 +1236,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testPopDirectory() throws Exception { public void testPopDirectory() throws Exception {
String fileName = "testPopDirectory.c"; String fileName = "testPopDirectory.c";
@ -1247,6 +1265,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testPushPop_WithNoLevel() throws Exception { public void testPushPop_WithNoLevel() throws Exception {
String fileName = getName() + ".c"; String fileName = getName() + ".c";
@ -1275,6 +1294,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testPushDirectoryAndCache() throws Exception { public void testPushDirectoryAndCache() throws Exception {
String fileName = "testPushDirectoryCacheProblem.c"; String fileName = "testPushDirectoryCacheProblem.c";
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -1307,6 +1327,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDisablePushDirectoryOnParallelBuild_J() throws Exception { public void testDisablePushDirectoryOnParallelBuild_J() throws Exception {
String fileName = getName() + ".c"; String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -1330,6 +1351,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDisablePushDirectoryOnParallelBuild_J2() throws Exception { public void testDisablePushDirectoryOnParallelBuild_J2() throws Exception {
String fileName = getName() + ".c"; String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -1353,6 +1375,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDisablePushDirectoryOnParallelBuild_J_2() throws Exception { public void testDisablePushDirectoryOnParallelBuild_J_2() throws Exception {
String fileName = getName() + ".c"; String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -1376,6 +1399,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDisablePushDirectoryOnParallelBuild_J1() throws Exception { public void testDisablePushDirectoryOnParallelBuild_J1() throws Exception {
String fileName = getName() + ".c"; String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -1399,6 +1423,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDisablePushDirectoryOnParallelBuild_J_1() throws Exception { public void testDisablePushDirectoryOnParallelBuild_J_1() throws Exception {
String fileName = getName() + ".c"; String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -1422,6 +1447,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDisablePushDirectoryOnParallelBuild_Jobs() throws Exception { public void testDisablePushDirectoryOnParallelBuild_Jobs() throws Exception {
String fileName = getName() + ".c"; String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -1445,6 +1471,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDisablePushDirectoryOnParallelBuild_Jobs1() throws Exception { public void testDisablePushDirectoryOnParallelBuild_Jobs1() throws Exception {
String fileName = getName() + ".c"; String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -1468,6 +1495,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDisablePushDirectoryOnParallelBuild_gmake() throws Exception { public void testDisablePushDirectoryOnParallelBuild_gmake() throws Exception {
String fileName = getName() + ".c"; String fileName = getName() + ".c";
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
@ -1491,6 +1519,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testMappedRemoteAbsolutePath_Bug264704() throws Exception { public void testMappedRemoteAbsolutePath_Bug264704() throws Exception {
ResourceHelper.createFolder(fProject, "Folder"); ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFolder(fProject, "Folder/AbsoluteRemoteFolder"); ResourceHelper.createFolder(fProject, "Folder/AbsoluteRemoteFolder");
@ -1511,6 +1540,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testMappedRemoteAbsolutePathAnotherProject_Bug264704() throws Exception { public void testMappedRemoteAbsolutePathAnotherProject_Bug264704() throws Exception {
IProject anotherProject = ResourceHelper.createCDTProject("ProjectMappedRemoteAbsolutePathAnotherProject"); IProject anotherProject = ResourceHelper.createCDTProject("ProjectMappedRemoteAbsolutePathAnotherProject");
@ -1536,6 +1566,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testWindowsPathOnLinux_Bug263977() throws Exception { public void testWindowsPathOnLinux_Bug263977() throws Exception {
// This test is valid on Unix platforms only // This test is valid on Unix platforms only
boolean isUnix = Platform.getOS().equals(Platform.OS_LINUX) || Platform.getOS().equals(Platform.OS_AIX) boolean isUnix = Platform.getOS().equals(Platform.OS_LINUX) || Platform.getOS().equals(Platform.OS_AIX)

View file

@ -14,6 +14,10 @@
package org.eclipse.cdt.core.internal.errorparsers.tests; 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.ByteArrayInputStream;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; 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.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin; 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.internal.registry.ExtensionRegistry;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource; 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.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.junit.jupiter.api.BeforeEach;
import junit.framework.TestCase; import org.junit.jupiter.api.Test;
import junit.framework.TestSuite;
/** /**
* @author Alena Laskavaia * @author Alena Laskavaia
* *
* Tests for ErrorParser manager and different parsers * Tests for ErrorParser manager and different parsers
*/ */
public class ErrorParserManagerTest extends TestCase { public class ErrorParserManagerTest extends BaseTestCase5 {
IWorkspace workspace; IWorkspace workspace;
IWorkspaceRoot root; IWorkspaceRoot root;
@ -61,14 +65,6 @@ public class ErrorParserManagerTest extends TestCase {
private ArrayList<ProblemMarkerInfo> errorList; private ArrayList<ProblemMarkerInfo> errorList;
private IMarkerGenerator markerGenerator; private IMarkerGenerator markerGenerator;
/**
* Constructor for CModelTests.
* @param name
*/
public ErrorParserManagerTest(String name) {
super(name);
}
/** /**
* Sets up the test fixture. * Sets up the test fixture.
* *
@ -77,8 +73,8 @@ public class ErrorParserManagerTest extends TestCase {
* Example code test the packages in the project * Example code test the packages in the project
* "com.qnx.tools.ide.cdt.core" * "com.qnx.tools.ide.cdt.core"
*/ */
@Override @BeforeEach
protected void setUp() throws Exception { protected void beforeEach() throws Exception {
/*** /***
* The test of the tests assume that they have a working workspace * The test of the tests assume that they have a working workspace
* and workspace root object to use to create projects/files in, * 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); 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 { private ICProject createProject(String name) throws CoreException {
ICProject testProject; ICProject testProject;
testProject = CProjectHelper.createCProject(name, "none", IPDOMManager.ID_NO_INDEXER); testProject = CProjectHelper.createCProject(name, "none", IPDOMManager.ID_NO_INDEXER);
@ -152,6 +130,7 @@ public class ErrorParserManagerTest extends TestCase {
epManager.getOutputStream().close(); epManager.getOutputStream().close();
} }
@Test
public void testParsersSanity() throws CoreException, IOException { public void testParsersSanity() throws CoreException, IOException {
output("catchpoints.cpp:12: warning: no return statement in function returning non-void\n"); output("catchpoints.cpp:12: warning: no return statement in function returning non-void\n");
end(); end();
@ -162,6 +141,7 @@ public class ErrorParserManagerTest extends TestCase {
assertEquals(new Path("catchpoints.cpp"), problemMarkerInfo.externalPath); assertEquals(new Path("catchpoints.cpp"), problemMarkerInfo.externalPath);
} }
@Test
public void testParsersSanityTrimmed() throws CoreException, IOException { public void testParsersSanityTrimmed() throws CoreException, IOException {
output(" catchpoints.cpp:12: warning: no return statement in function returning non-void \n"); output(" catchpoints.cpp:12: warning: no return statement in function returning non-void \n");
end(); end();
@ -172,6 +152,7 @@ public class ErrorParserManagerTest extends TestCase {
assertEquals(new Path("catchpoints.cpp"), problemMarkerInfo.externalPath); assertEquals(new Path("catchpoints.cpp"), problemMarkerInfo.externalPath);
} }
@Test
public void testOutput() throws IOException { public void testOutput() throws IOException {
try (FileInputStream fileInputStream = new FileInputStream( try (FileInputStream fileInputStream = new FileInputStream(
CTestPlugin.getDefault().getFileInPlugin(new Path("resources/errortests/output-1")))) { 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()), boolean added = Platform.getExtensionRegistry().addContribution(new ByteArrayInputStream(ext.getBytes()),
contributor, false, shortId, null, contributor, false, shortId, null,
((ExtensionRegistry) Platform.getExtensionRegistry()).getTemporaryUserToken()); ((ExtensionRegistry) Platform.getExtensionRegistry()).getTemporaryUserToken());
assertTrue("failed to add extension", added); assertTrue(added, "failed to add extension");
String fullId = "org.eclipse.cdt.core.tests." + shortId; String fullId = "org.eclipse.cdt.core.tests." + shortId;
IErrorParser[] errorParser = CCorePlugin.getDefault().getErrorParser(fullId); IErrorParser[] errorParser = CCorePlugin.getDefault().getErrorParser(fullId);
assertTrue(errorParser.length > 0); assertTrue(errorParser.length > 0);
@ -227,6 +208,7 @@ public class ErrorParserManagerTest extends TestCase {
} }
} }
@Test
public void testNoTrimParser() throws IOException { public void testNoTrimParser() throws IOException {
String id = addErrorParserExtension("test1", TestParser1.class); String id = addErrorParserExtension("test1", TestParser1.class);
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id }); epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id });
@ -256,6 +238,7 @@ public class ErrorParserManagerTest extends TestCase {
} }
} }
@Test
public void testLongLinesParser() throws IOException { public void testLongLinesParser() throws IOException {
String id = addErrorParserExtension("test2", TestParser2.class); String id = addErrorParserExtension("test2", TestParser2.class);
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id }); epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id });
@ -293,6 +276,7 @@ public class ErrorParserManagerTest extends TestCase {
} }
} }
@Test
public void testLongLinesUntrimmedParser() throws IOException { public void testLongLinesUntrimmedParser() throws IOException {
String id = addErrorParserExtension("test3", TestParser3.class); String id = addErrorParserExtension("test3", TestParser3.class);
epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id }); epManager = new ErrorParserManager(cProject.getProject(), markerGenerator, new String[] { id });
@ -323,6 +307,7 @@ public class ErrorParserManagerTest extends TestCase {
} }
} }
@Test
public void testWorkspaceLevelError() throws IOException { public void testWorkspaceLevelError() throws IOException {
String id = addErrorParserExtension("test4", TestParser4.class); String id = addErrorParserExtension("test4", TestParser4.class);
epManager = new ErrorParserManager(null, markerGenerator, new String[] { id }); epManager = new ErrorParserManager(null, markerGenerator, new String[] { id });

View file

@ -17,42 +17,27 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.stream.Stream;
import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.junit.jupiter.params.ParameterizedTest;
import junit.framework.Test; import org.junit.jupiter.params.provider.Arguments;
import junit.framework.TestSuite; import org.junit.jupiter.params.provider.MethodSource;
public class FileBasedErrorParserTests extends GenericErrorParserTests { public class FileBasedErrorParserTests extends GenericErrorParserTests {
@ParameterizedTest
File errorFile; @MethodSource("provideFilenames")
public void testErrorsInFiles(File errorFile) throws IOException {
public FileBasedErrorParserTests(File file) {
super("testErrorsInFiles");
errorFile = file;
}
@Override
public String getName() {
return super.getName() + " " + errorFile.getName();
}
public void testErrorsInFiles() throws IOException {
InputStream stream = new FileInputStream(errorFile); InputStream stream = new FileInputStream(errorFile);
runParserTest(stream, -1, -1, null, null, new String[] { GCC_ERROR_PARSER_ID }); runParserTest(stream, -1, -1, null, null, new String[] { GCC_ERROR_PARSER_ID });
stream.close(); stream.close();
} }
public static Test suite() { public static Stream<Arguments> provideFilenames() {
TestSuite suite = new TestSuite(FileBasedErrorParserTests.class.getName());
File dir = CTestPlugin.getDefault().getFileInPlugin(new Path("resources/errortests/")); File dir = CTestPlugin.getDefault().getFileInPlugin(new Path("resources/errortests/"));
File[] testsfiles = dir.listFiles(); File[] testsfiles = dir.listFiles();
for (int i = 0; i < testsfiles.length; i++) { return Stream.of(testsfiles).map(Arguments::of);
if (testsfiles[i].isFile())
suite.addTest(new FileBasedErrorParserTests(testsfiles[i]));
}
return suite;
} }
} }

View file

@ -16,8 +16,7 @@ package org.eclipse.cdt.core.internal.errorparsers.tests;
import java.io.IOException; import java.io.IOException;
import junit.framework.Test; import org.junit.jupiter.api.Test;
import junit.framework.TestSuite;
/** /**
* This test is designed to exercise the error parser capabilities. * 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 int GCC_ERROR_STREAM5_ERRORS = 2;
public static final String[] GCC_ERROR_STREAM5_FILENAMES = { "main.c" }; public static final String[] GCC_ERROR_STREAM5_FILENAMES = { "main.c" };
/** @Test
* Constructor for IndexManagerTest.
*
* @param name
*/
public GCCErrorParserTests() {
super();
}
public static Test suite() {
TestSuite suite = new TestSuite(GCCErrorParserTests.class);
return suite;
}
public void testMultipleIncludesError() throws IOException { public void testMultipleIncludesError() throws IOException {
runParserTest(GCC_ERROR_STREAM1, GCC_ERROR_STREAM1_ERRORS, GCC_ERROR_STREAM1_WARNINGS, runParserTest(GCC_ERROR_STREAM1, GCC_ERROR_STREAM1_ERRORS, GCC_ERROR_STREAM1_WARNINGS,
GCC_ERROR_STREAM1_FILENAMES, null, new String[] { GCC_ERROR_PARSER_ID }); 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 * I brought this up in http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg08668.html
* but did not get any replies. * 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, 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}); 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, 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}); 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, 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}); GCC_ERROR_STREAM4_DESCRIPTIONS, new String[]{GCC_ERROR_PARSER_ID});
} }
*/ */
@Test
public void testBasicMessages() throws IOException { public void testBasicMessages() throws IOException {
runParserTest(GCC_ERROR_STREAM5, GCC_ERROR_STREAM5_ERRORS, GCC_ERROR_STREAM5_WARNINGS, runParserTest(GCC_ERROR_STREAM5, GCC_ERROR_STREAM5_ERRORS, GCC_ERROR_STREAM5_WARNINGS,
GCC_ERROR_STREAM5_FILENAMES, null, new String[] { GCC_ERROR_PARSER_ID }); GCC_ERROR_STREAM5_FILENAMES, null, new String[] { GCC_ERROR_PARSER_ID });
} }
@Test
public void testGccErrorMessages_Colon_bug263987() throws IOException { public void testGccErrorMessages_Colon_bug263987() throws IOException {
runParserTest(new String[] { runParserTest(new String[] {
"foo.cc:11:20: error: value with length 0 violates the length restriction: length (1 .. infinity)", }, "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 }); new String[] { GCC_ERROR_PARSER_ID });
} }
@Test
public void testGccErrorMessages_C90Comments_bug193982() throws IOException { public void testGccErrorMessages_C90Comments_bug193982() throws IOException {
runParserTest( runParserTest(
new String[] { "Myfile.c:66:3: warning: C++ style comments are not allowed in ISO C90", 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 }); new String[] { GCC_ERROR_PARSER_ID });
} }
@Test
public void testGccErrorMessages_ConflictingTypes() throws IOException { public void testGccErrorMessages_ConflictingTypes() throws IOException {
runParserTest( runParserTest(
new String[] { "bar.h:42: error: conflicting types for 'jmp_buf'", 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 }); new String[] { GCC_ERROR_PARSER_ID });
} }
@Test
public void testGccErrorMessages_InstantiatedFromHere() throws IOException { public void testGccErrorMessages_InstantiatedFromHere() throws IOException {
runParserTest(new String[] { 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>]'", "/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 }); new String[] { GCC_ERROR_PARSER_ID });
} }
@Test
public void testGccErrorMessages_RequiredFromHere() throws IOException { public void testGccErrorMessages_RequiredFromHere() throws IOException {
runParserTest(new String[] { 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>]'", "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 }); new String[] { GCC_ERROR_PARSER_ID });
} }
@Test
public void testGccErrorMessages_Infos() throws IOException { public void testGccErrorMessages_Infos() throws IOException {
runParserTest( runParserTest(
new String[] { "foo.c:5: note: Offset of packed bit-field 'b' has changed in GCC 4.4", 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 }); new String[] { GCC_ERROR_PARSER_ID });
} }
@Test
public void testGccErrorMessages_DangerousFunction_bug248669() throws IOException { public void testGccErrorMessages_DangerousFunction_bug248669() throws IOException {
runParserTest( runParserTest(
new String[] { "mktemp.o(.text+0x19): In function 'main':", new String[] { "mktemp.o(.text+0x19): In function 'main':",
@ -206,6 +200,7 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
new String[] { GCC_ERROR_PARSER_ID }); new String[] { GCC_ERROR_PARSER_ID });
} }
@Test
public void testGccErrorMessages_TemplateInstantiation_bug500798() throws IOException { public void testGccErrorMessages_TemplateInstantiation_bug500798() throws IOException {
runParserTest(new String[] { runParserTest(new String[] {
"test.hpp:309:18: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]", "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 }); new String[] { GCC_ERROR_PARSER_ID });
} }
@Test
public void testGccErrorMessages_InConstexprExpansion() throws IOException { public void testGccErrorMessages_InConstexprExpansion() throws IOException {
runParserTest( runParserTest(
new String[] { "../can/CANBus.h: In instantiation of 'constexpr void Test::setupBitrate(T)':", new String[] { "../can/CANBus.h: In instantiation of 'constexpr void Test::setupBitrate(T)':",

View file

@ -15,23 +15,14 @@ package org.eclipse.cdt.core.internal.errorparsers.tests;
import java.io.IOException; import java.io.IOException;
import junit.framework.Test; import org.junit.jupiter.api.Test;
import junit.framework.TestSuite;
/** /**
* This test is designed to exercise the error parser capabilities for GNU ld. * This test is designed to exercise the error parser capabilities for GNU ld.
*/ */
public class GLDErrorParserTests extends GenericErrorParserTests { public class GLDErrorParserTests extends GenericErrorParserTests {
public GLDErrorParserTests() { @Test
super();
}
public static Test suite() {
TestSuite suite = new TestSuite(GLDErrorParserTests.class);
return suite;
}
public void testLinkerMessages0() throws IOException { public void testLinkerMessages0() throws IOException {
runParserTest( runParserTest(
// old style: no colons before sections // old style: no colons before sections
@ -48,6 +39,7 @@ public class GLDErrorParserTests extends GenericErrorParserTests {
new String[] { GLD_ERROR_PARSER_ID }); new String[] { GLD_ERROR_PARSER_ID });
} }
@Test
public void testLinkerMessages1() throws IOException { public void testLinkerMessages1() throws IOException {
runParserTest( runParserTest(
// new style: colons before sections // new style: colons before sections
@ -64,6 +56,7 @@ public class GLDErrorParserTests extends GenericErrorParserTests {
new String[] { GLD_ERROR_PARSER_ID }); new String[] { GLD_ERROR_PARSER_ID });
} }
@Test
public void testLinkerMessages2() throws IOException { public void testLinkerMessages2() throws IOException {
runParserTest( runParserTest(
new String[] { "make -k all", "gcc -o hallo.o main.c libfoo.a", "libfoo.a(foo.o): In function `foo':", 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 }); new String[] { GLD_ERROR_PARSER_ID });
} }
@Test
public void testLinkerMessages_DangerousFunction_bug248669() throws IOException { public void testLinkerMessages_DangerousFunction_bug248669() throws IOException {
runParserTest(new String[] { "mktemp.o(.text+0x19): In function 'main':", 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':", "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 }); new String[] { GLD_ERROR_PARSER_ID });
} }
@Test
public void testLinkerMessages_PrecedingPath_bug314253() throws IOException { public void testLinkerMessages_PrecedingPath_bug314253() throws IOException {
runParserTest(new String[] { runParserTest(new String[] {
"ld: warning: libstdc++.so.5, needed by testlib_1.so, may conflict with libstdc++.so.6", "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 }); new String[] { GLD_ERROR_PARSER_ID });
} }
@Test
public void testLinkerMessages_bug495661() throws IOException { public void testLinkerMessages_bug495661() throws IOException {
runParserTest( runParserTest(
// new style: colons before sections // new style: colons before sections

View file

@ -13,6 +13,10 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.internal.errorparsers.tests; 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.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -25,57 +29,38 @@ import java.util.List;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.ProblemMarkerInfo; 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.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.jupiter.api.AfterEach;
import junit.framework.TestCase; import org.junit.jupiter.api.BeforeEach;
/** /**
* This test is designed to exercise the error parser capabilities. * 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 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 GLD_ERROR_PARSER_ID = "org.eclipse.cdt.core.GLDErrorParser";
public static final String GMAKE_ERROR_PARSER_ID = "org.eclipse.cdt.core.GmakeErrorParser"; public static final String GMAKE_ERROR_PARSER_ID = "org.eclipse.cdt.core.GmakeErrorParser";
protected IProject fTempProject; protected IProject fTempProject;
/** @BeforeEach
* Constructor for IndexManagerTest. protected void beforeEachCreateProject() throws Exception {
*
* @param name
*/
public GenericErrorParserTests(String name) {
super(name);
}
public GenericErrorParserTests() {
super();
}
@Override
protected void setUp() throws Exception {
super.setUp();
fTempProject = ResourcesPlugin.getWorkspace().getRoot().getProject("temp-" + System.currentTimeMillis()); fTempProject = ResourcesPlugin.getWorkspace().getRoot().getProject("temp-" + System.currentTimeMillis());
if (!fTempProject.exists()) { if (!fTempProject.exists()) {
fTempProject.create(new NullProgressMonitor()); fTempProject.create(new NullProgressMonitor());
} }
} }
@Override @AfterEach
protected void tearDown() { protected void afterEachDeleteProject() throws CoreException {
try { fTempProject.delete(true, true, new NullProgressMonitor());
super.tearDown();
} catch (Exception ex) {
}
try {
fTempProject.delete(true, true, new NullProgressMonitor());
} catch (Exception ex) {
}
} }
protected IProject getTempProject() { protected IProject getTempProject() {

View file

@ -13,12 +13,12 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.internal.errorparsers.tests; package org.eclipse.cdt.core.internal.errorparsers.tests;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException; import java.io.IOException;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.junit.jupiter.api.Test;
import junit.framework.Test;
import junit.framework.TestSuite;
/** /**
* This test is designed to exercise the error parser capabilities for GNU make. * 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_WARNINGS = 0;
private static final int GMAKE_ERROR_STREAM2_ERRORS = 3; private static final int GMAKE_ERROR_STREAM2_ERRORS = 3;
public MakeErrorParserTests() { @Test
super();
}
public static Test suite() {
TestSuite suite = new TestSuite(MakeErrorParserTests.class);
return suite;
}
public void testGmakeSanity() throws Exception { public void testGmakeSanity() throws Exception {
assertNotNull(ErrorParserManager.getErrorParserCopy(GMAKE_ERROR_PARSER_ID)); assertNotNull(ErrorParserManager.getErrorParserCopy(GMAKE_ERROR_PARSER_ID));
} }
@Test
public void testGmakeMessages0() throws IOException { public void testGmakeMessages0() throws IOException {
runParserTest(GMAKE_ERROR_STREAM0, GMAKE_ERROR_STREAM0_ERRORS, GMAKE_ERROR_STREAM0_WARNINGS, runParserTest(GMAKE_ERROR_STREAM0, GMAKE_ERROR_STREAM0_ERRORS, GMAKE_ERROR_STREAM0_WARNINGS,
GMAKE_ERROR_STREAM0_INFOS, null, null, new String[] { GMAKE_ERROR_PARSER_ID }); GMAKE_ERROR_STREAM0_INFOS, null, null, new String[] { GMAKE_ERROR_PARSER_ID });
} }
@Test
public void testGMakeMessages1() throws IOException { public void testGMakeMessages1() throws IOException {
runParserTest(GMAKE_ERROR_STREAM1, GMAKE_ERROR_STREAM1_ERRORS, GMAKE_ERROR_STREAM1_WARNINGS, runParserTest(GMAKE_ERROR_STREAM1, GMAKE_ERROR_STREAM1_ERRORS, GMAKE_ERROR_STREAM1_WARNINGS,
GMAKE_ERROR_STREAM1_FILENAMES, null, new String[] { GMAKE_ERROR_PARSER_ID }); GMAKE_ERROR_STREAM1_FILENAMES, null, new String[] { GMAKE_ERROR_PARSER_ID });
} }
@Test
public void testGmakeMessages2() throws IOException { public void testGmakeMessages2() throws IOException {
runParserTest(GMAKE_ERROR_STREAM2, GMAKE_ERROR_STREAM2_ERRORS, GMAKE_ERROR_STREAM2_WARNINGS, null, null, runParserTest(GMAKE_ERROR_STREAM2, GMAKE_ERROR_STREAM2_ERRORS, GMAKE_ERROR_STREAM2_WARNINGS, null, null,
new String[] { GMAKE_ERROR_PARSER_ID }); new String[] { GMAKE_ERROR_PARSER_ID });

View file

@ -14,6 +14,13 @@
package org.eclipse.cdt.core.internal.errorparsers.tests; 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 java.util.ArrayList;
import org.eclipse.cdt.core.CCorePlugin; 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.errorparsers.RegexErrorPattern;
import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.cdt.core.testplugin.ResourceHelper; 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.ErrorParserExtensionManager;
import org.eclipse.cdt.internal.errorparsers.GASErrorParser; import org.eclipse.cdt.internal.errorparsers.GASErrorParser;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.junit.jupiter.api.AfterEach;
import junit.framework.TestCase; import org.junit.jupiter.api.BeforeEach;
import junit.framework.TestSuite; import org.junit.jupiter.api.Test;
/** /**
* Test cases testing RegexErrorParser functionality * 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 // 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_ID = "org.eclipse.cdt.core.tests.RegexErrorParserId";
private static final String REGEX_ERRORPARSER_NAME = "Test Plugin RegexErrorParser"; private static final String REGEX_ERRORPARSER_NAME = "Test Plugin RegexErrorParser";
@ -78,51 +86,24 @@ public class RegexErrorParserTests extends TestCase {
} }
} }
/** @BeforeEach
* Constructor. protected void beforeEach() throws Exception {
* @param name - name of the test.
*/
public RegexErrorParserTests(String name) {
super(name);
}
@Override
protected void setUp() throws Exception {
fProject = ResourceHelper.createCDTProject(TEST_PROJECT_NAME); fProject = ResourceHelper.createCDTProject(TEST_PROJECT_NAME);
assertNotNull(fProject); assertNotNull(fProject);
errorList = new ArrayList<>(); errorList = new ArrayList<>();
} }
@Override @AfterEach
protected void tearDown() throws Exception { protected void resetUserDefinedErrorParsers() throws Exception {
ResourceHelper.cleanUp(getName());
fProject = null;
ErrorParserManager.setUserDefinedErrorParsers(null); 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. * Check if error pattern can be added/deleted.
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRegexErrorParserAddDeletePattern() throws Exception { public void testRegexErrorParserAddDeletePattern() throws Exception {
RegexErrorParser regexErrorParser = new RegexErrorParser(); RegexErrorParser regexErrorParser = new RegexErrorParser();
regexErrorParser.addPattern( regexErrorParser.addPattern(
@ -151,6 +132,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRegexErrorParserPatternOrder() throws Exception { public void testRegexErrorParserPatternOrder() throws Exception {
final int ERR = IMarkerGenerator.SEVERITY_ERROR_RESOURCE; final int ERR = IMarkerGenerator.SEVERITY_ERROR_RESOURCE;
RegexErrorParser regexErrorParser = new RegexErrorParser(); RegexErrorParser regexErrorParser = new RegexErrorParser();
@ -186,7 +168,11 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRegexErrorParserParseOutput() throws Exception { public void testRegexErrorParserParseOutput() throws Exception {
// This test generates an expected error in the log
setExpectedNumberOfLoggedNonOKStatusObjects(1);
RegexErrorParser regexErrorParser = new RegexErrorParser(); RegexErrorParser regexErrorParser = new RegexErrorParser();
regexErrorParser.addPattern(new RegexErrorPattern("(.*)#(.*)#(.*)#(.*)", "$1", "$2", "$3 $4", "var=$4", regexErrorParser.addPattern(new RegexErrorPattern("(.*)#(.*)#(.*)#(.*)", "$1", "$2", "$3 $4", "var=$4",
IMarkerGenerator.SEVERITY_ERROR_RESOURCE, true)); IMarkerGenerator.SEVERITY_ERROR_RESOURCE, true));
@ -261,6 +247,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testCompatibility() throws Exception { public void testCompatibility() throws Exception {
final CCorePlugin cCorePlugin = CCorePlugin.getDefault(); final CCorePlugin cCorePlugin = CCorePlugin.getDefault();
@ -280,6 +267,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testExtension() throws Exception { public void testExtension() throws Exception {
// ErrorParserManager.getErrorParser // ErrorParserManager.getErrorParser
{ {
@ -322,6 +310,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testExtensionsSorting() throws Exception { public void testExtensionsSorting() throws Exception {
{ {
String[] ids = ErrorParserManager.getErrorParserExtensionIds(); String[] ids = ErrorParserManager.getErrorParserExtensionIds();
@ -339,14 +328,14 @@ public class RegexErrorParserTests extends TestCase {
// inside the same category sorted by names // inside the same category sorted by names
if (lastIsDeprecated == isDeprecated && lastIsTestPlugin == isTestPlugin) { 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) // deprecated follow non-deprecated (unless parsers from test plugin show up)
if (lastIsTestPlugin == isTestPlugin) { if (lastIsTestPlugin == isTestPlugin) {
assertFalse(message, lastIsDeprecated == true && isDeprecated == false); assertFalse(lastIsDeprecated == true && isDeprecated == false, message);
} }
// error parsers from test plugin are the last // error parsers from test plugin are the last
assertFalse(message, lastIsTestPlugin == true && isTestPlugin == false); assertFalse(lastIsTestPlugin == true && isTestPlugin == false, message);
lastName = name; lastName = name;
lastIsDeprecated = isDeprecated; lastIsDeprecated = isDeprecated;
@ -360,6 +349,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testAvailableErrorParsers() throws Exception { public void testAvailableErrorParsers() throws Exception {
final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser"; final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser";
final String TESTING_NAME = "An error parser"; final String TESTING_NAME = "An error parser";
@ -438,6 +428,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testUserDefinedErrorParsers() throws Exception { public void testUserDefinedErrorParsers() throws Exception {
final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser"; final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser";
final String TESTING_NAME = "An error parser"; final String TESTING_NAME = "An error parser";
@ -469,6 +460,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testDefaultErrorParserIds() throws Exception { public void testDefaultErrorParserIds() throws Exception {
final String[] availableParserIds = ErrorParserManager.getErrorParserAvailableIds(); final String[] availableParserIds = ErrorParserManager.getErrorParserAvailableIds();
assertNotNull(availableParserIds); assertNotNull(availableParserIds);
@ -507,6 +499,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testSerializeErrorParser() throws Exception { public void testSerializeErrorParser() throws Exception {
final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser"; final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser";
final String TESTING_NAME = "An error parser"; final String TESTING_NAME = "An error parser";
@ -549,6 +542,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testSerializeRegexErrorParser() throws Exception { public void testSerializeRegexErrorParser() throws Exception {
final String TESTING_ID = "org.eclipse.cdt.core.test.regexerrorparser"; final String TESTING_ID = "org.eclipse.cdt.core.test.regexerrorparser";
@ -609,6 +603,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testSerializeRegexErrorParserSpecialCharacters() throws Exception { public void testSerializeRegexErrorParserSpecialCharacters() throws Exception {
final String TESTING_ID = "org.eclipse.cdt.core.test.regexerrorparser"; final String TESTING_ID = "org.eclipse.cdt.core.test.regexerrorparser";
@ -653,6 +648,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testSerializeDefaultErrorParserIds() throws Exception { public void testSerializeDefaultErrorParserIds() throws Exception {
final String[] testingDefaultErrorParserIds = { "org.eclipse.cdt.core.test.errorparser0", final String[] testingDefaultErrorParserIds = { "org.eclipse.cdt.core.test.errorparser0",
"org.eclipse.cdt.core.test.errorparser1", "org.eclipse.cdt.core.test.errorparser2", }; "org.eclipse.cdt.core.test.errorparser1", "org.eclipse.cdt.core.test.errorparser2", };
@ -705,6 +701,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testGetErrorParserCopy() throws Exception { public void testGetErrorParserCopy() throws Exception {
{ {
IErrorParserNamed clone1 = ErrorParserManager.getErrorParserCopy(REGEX_ERRORPARSER_ID); IErrorParserNamed clone1 = ErrorParserManager.getErrorParserCopy(REGEX_ERRORPARSER_ID);
@ -731,6 +728,7 @@ public class RegexErrorParserTests extends TestCase {
* *
* @throws Exception... * @throws Exception...
*/ */
@Test
public void testRegexErrorParserExternalLocation_bug301338() throws Exception { public void testRegexErrorParserExternalLocation_bug301338() throws Exception {
RegexErrorParser regexErrorParser = new RegexErrorParser(); RegexErrorParser regexErrorParser = new RegexErrorParser();
regexErrorParser.addPattern( regexErrorParser.addPattern(

View file

@ -13,21 +13,19 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.internal.tests; 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 java.util.Random;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
import org.eclipse.cdt.internal.core.PositionTracker; import org.eclipse.cdt.internal.core.PositionTracker;
import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region; import org.eclipse.jface.text.Region;
import org.junit.jupiter.api.Test;
import junit.framework.Test; public class PositionTrackerTests extends BaseTestCase5 {
import junit.framework.TestCase; @Test
import junit.framework.TestSuite;
public class PositionTrackerTests extends TestCase {
public static Test suite() {
return new TestSuite(PositionTrackerTests.class);
}
public void testInitialFailures() { public void testInitialFailures() {
int[][] moves = { 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, { 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() { 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 }, 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 }, { 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() { public void testDepth4() {
fullTest(5, 4); fullTest(5, 4);
} }
@Test
public void testRandomDepth5() { public void testRandomDepth5() {
randomTest(20, 5, 5, 1000); randomTest(20, 5, 5, 1000);
} }
@Test
public void testRandomDepth10() { public void testRandomDepth10() {
randomTest(50, 10, 10, 1000); randomTest(50, 10, 10, 1000);
} }
@Test
public void testRandomDepth15() { public void testRandomDepth15() {
randomTest(100, 15, 15, 1000); randomTest(100, 15, 15, 1000);
} }
@Test
public void testRandomDepth20() { public void testRandomDepth20() {
randomTest(100, 15, 20, 1000); randomTest(100, 15, 20, 1000);
} }
@Test
public void testRetireDepth2() { public void testRetireDepth2() {
randomRetireTest(100, 10, 25, 2, 1000); randomRetireTest(100, 10, 25, 2, 1000);
} }
@Test
public void testRetireDepth5() { public void testRetireDepth5() {
randomRetireTest(100, 10, 10, 5, 1000); randomRetireTest(100, 10, 10, 5, 1000);
} }
@Test
public void testRetireDepth10() { public void testRetireDepth10() {
randomRetireTest(100, 10, 5, 10, 1000); randomRetireTest(100, 10, 5, 10, 1000);
} }
@ -242,6 +249,7 @@ public class PositionTrackerTests extends TestCase {
return false; return false;
} }
@Test
public void testInsertion() { public void testInsertion() {
PositionTracker pt = new PositionTracker(); PositionTracker pt = new PositionTracker();
pt.insert(1, 1); pt.insert(1, 1);
@ -266,6 +274,7 @@ public class PositionTrackerTests extends TestCase {
doubleRangeCheck(pt, new Region(1, 0), new Region(2, 0)); doubleRangeCheck(pt, new Region(1, 0), new Region(2, 0));
} }
@Test
public void testDeletion() { public void testDeletion() {
PositionTracker pt = new PositionTracker(); PositionTracker pt = new PositionTracker();
pt.delete(1, 1); pt.delete(1, 1);
@ -288,6 +297,7 @@ public class PositionTrackerTests extends TestCase {
doubleRangeCheck(pt, new Region(2, 0), new Region(1, 0)); doubleRangeCheck(pt, new Region(2, 0), new Region(1, 0));
} }
@Test
public void testReplace() { public void testReplace() {
PositionTracker pt = new PositionTracker(); PositionTracker pt = new PositionTracker();
pt.delete(1, 1); pt.delete(1, 1);

View file

@ -14,12 +14,14 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.internal.tests; package org.eclipse.cdt.core.internal.tests;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; 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.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; 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.IPath;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; 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; public class ResourceLookupTests extends BaseTestCase5 {
import junit.framework.TestSuite;
public class ResourceLookupTests extends BaseTestCase {
public static Test suite() {
return new TestSuite(ResourceLookupTests.class);
}
private IProject fProject; private IProject fProject;
@Override @BeforeEach
protected void setUp() throws Exception { protected void beforeEach() throws Exception {
super.setUp();
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
fProject = root.getProject("reslookup_" + getName()); fProject = root.getProject("reslookup_" + getName());
} }
@Override @AfterEach
protected void tearDown() throws Exception { protected void afterEach() throws Exception {
fProject.delete(true, new NullProgressMonitor()); fProject.delete(true, true, new NullProgressMonitor());
super.tearDown();
} }
protected IFolder createFolder(IProject project, String filename) throws CoreException { protected IFolder createFolder(IProject project, String filename) throws CoreException {
@ -71,6 +68,7 @@ public class ResourceLookupTests extends BaseTestCase {
return file; return file;
} }
@Test
public void testNameLookup() throws CoreException { public void testNameLookup() throws CoreException {
IProject[] prjs = new IProject[] { fProject }; IProject[] prjs = new IProject[] { fProject };
@ -112,6 +110,7 @@ public class ResourceLookupTests extends BaseTestCase {
assertEquals(3, files.length); assertEquals(3, files.length);
} }
@Test
public void testResourceDelta() throws CoreException { public void testResourceDelta() throws CoreException {
IProject[] prjs = new IProject[] { fProject }; IProject[] prjs = new IProject[] { fProject };
fProject.create(new NullProgressMonitor()); fProject.create(new NullProgressMonitor());
@ -143,6 +142,7 @@ public class ResourceLookupTests extends BaseTestCase {
assertEquals(1, files.length); assertEquals(1, files.length);
} }
@Test
public void testDeref() throws CoreException { public void testDeref() throws CoreException {
IProject[] prjs = new IProject[] { fProject }; IProject[] prjs = new IProject[] { fProject };
@ -166,6 +166,7 @@ public class ResourceLookupTests extends BaseTestCase {
assertEquals(3, files.length); assertEquals(3, files.length);
} }
@Test
public void testCollected() throws CoreException { public void testCollected() throws CoreException {
IProject[] prjs = new IProject[] { fProject }; IProject[] prjs = new IProject[] { fProject };
@ -189,6 +190,7 @@ public class ResourceLookupTests extends BaseTestCase {
assertEquals(3, files.length); assertEquals(3, files.length);
} }
@Test
public void testFindFilesByLocation() throws Exception { public void testFindFilesByLocation() throws Exception {
fProject.create(new NullProgressMonitor()); fProject.create(new NullProgressMonitor());
fProject.open(new NullProgressMonitor()); fProject.open(new NullProgressMonitor());
@ -215,6 +217,7 @@ public class ResourceLookupTests extends BaseTestCase {
} }
} }
@Test
public void testLinkedResourceFiles() throws Exception { public void testLinkedResourceFiles() throws Exception {
IProject[] prjs = new IProject[] { fProject }; IProject[] prjs = new IProject[] { fProject };

View file

@ -14,17 +14,18 @@
package org.eclipse.cdt.core.internal.tests; 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 java.lang.reflect.Method;
import junit.framework.Test; import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
import junit.framework.TestCase; import org.junit.jupiter.api.Test;
import junit.framework.TestSuite;
public class StringBuilderTest extends TestCase { public class StringBuilderTest extends BaseTestCase5 {
public static Test suite() {
return new TestSuite(StringBuilderTest.class);
}
@Test
public void testSafe() { public void testSafe() {
StringBuilder b1 = new StringBuilder(); StringBuilder b1 = new StringBuilder();
StringBuilder b2 = new StringBuilder(); StringBuilder b2 = new StringBuilder();
@ -35,6 +36,7 @@ public class StringBuilderTest extends TestCase {
assertEquals("ab", b1.toString()); assertEquals("ab", b1.toString());
} }
@Test
public void testBug220158() { public void testBug220158() {
StringBuilder b1 = new StringBuilder(); StringBuilder b1 = new StringBuilder();
StringBuilder b2 = new StringBuilder(); StringBuilder b2 = new StringBuilder();
@ -44,6 +46,7 @@ public class StringBuilderTest extends TestCase {
assertEquals("ab", b1.toString()); assertEquals("ab", b1.toString());
} }
@Test
public void testStringBuilderMethods() throws Exception { public void testStringBuilderMethods() throws Exception {
Class clazz = StringBuilder.class; Class clazz = StringBuilder.class;
Method method = clazz.getMethod("append", CharSequence.class); Method method = clazz.getMethod("append", CharSequence.class);

View file

@ -13,6 +13,11 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.resources.tests; 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.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; 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.settings.model.WriteAccessException;
import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin; 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.resources.ResourceExclusion;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
import org.eclipse.core.resources.IFolder; 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.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.junit.jupiter.api.AfterEach;
import junit.framework.Test; import org.junit.jupiter.api.BeforeEach;
import junit.framework.TestCase; import org.junit.jupiter.api.Test;
import junit.framework.TestSuite;
/** /**
* @author crecoskie * @author crecoskie
* *
*/ */
public class RefreshScopeTests extends TestCase { public class RefreshScopeTests extends BaseTestCase5 {
private IProject fProject; private IProject fProject;
private IProject fGeneralProject; private IProject fGeneralProject;
@ -65,11 +70,8 @@ public class RefreshScopeTests extends TestCase {
private IFolder fFolder6; private IFolder fFolder6;
private String config1, config2; private String config1, config2;
/* (non-Javadoc) @BeforeEach
* @see junit.framework.TestCase#setUp() protected void beforeEach() throws Exception {
*/
@Override
protected void setUp() throws Exception {
// create project // create project
CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() { CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@ -141,14 +143,14 @@ public class RefreshScopeTests extends TestCase {
} }
/* (non-Javadoc) @AfterEach
* @see junit.framework.TestCase#tearDown() protected void afterEach() throws Exception {
*/
@Override
protected void tearDown() throws Exception {
fProject.delete(true, true, null); fProject.delete(true, true, null);
fGeneralProject.delete(true, true, null);
BaseTestCase5.assertWorkspaceIsEmpty();
} }
@Test
public void testAddDeleteResource() throws CoreException { public void testAddDeleteResource() throws CoreException {
RefreshScopeManager manager = RefreshScopeManager.getInstance(); RefreshScopeManager manager = RefreshScopeManager.getInstance();
@ -221,6 +223,7 @@ public class RefreshScopeTests extends TestCase {
assertEquals(config2_resourcesAfterDelete.contains(fProject), true); assertEquals(config2_resourcesAfterDelete.contains(fProject), true);
} }
@Test
public void testSetResourcesToExclusionsMapRefresh() { public void testSetResourcesToExclusionsMapRefresh() {
RefreshScopeManager manager = RefreshScopeManager.getInstance(); RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData(); manager.clearAllData();
@ -239,6 +242,7 @@ public class RefreshScopeTests extends TestCase {
} }
@Test
public void testAddRemoveExclusion() { public void testAddRemoveExclusion() {
RefreshScopeManager manager = RefreshScopeManager.getInstance(); RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData(); manager.clearAllData();
@ -272,6 +276,7 @@ public class RefreshScopeTests extends TestCase {
} }
@Test
public void testPersistAndLoad() { public void testPersistAndLoad() {
RefreshScopeManager manager = RefreshScopeManager.getInstance(); RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData(); manager.clearAllData();
@ -418,6 +423,7 @@ public class RefreshScopeTests extends TestCase {
manager.clearAllData(); manager.clearAllData();
} }
@Test
public void testResourceExclusion() { public void testResourceExclusion() {
RefreshScopeManager manager = RefreshScopeManager.getInstance(); RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData(); manager.clearAllData();
@ -534,6 +540,7 @@ public class RefreshScopeTests extends TestCase {
} }
@Test
public void testDefaults() { public void testDefaults() {
RefreshScopeManager manager = RefreshScopeManager.getInstance(); RefreshScopeManager manager = RefreshScopeManager.getInstance();
manager.clearAllData(); manager.clearAllData();
@ -602,6 +609,7 @@ public class RefreshScopeTests extends TestCase {
return conf.getName(); return conf.getName();
} }
@Test
public void testEmptyRefreshScopeCloseAndReopen() { public void testEmptyRefreshScopeCloseAndReopen() {
RefreshScopeManager manager = RefreshScopeManager.getInstance(); RefreshScopeManager manager = RefreshScopeManager.getInstance();
@ -641,6 +649,7 @@ public class RefreshScopeTests extends TestCase {
assertEquals(0, config_resources.size()); assertEquals(0, config_resources.size());
} }
@Test
public void testAddEmptyConfiguration() { public void testAddEmptyConfiguration() {
final String CFG_NAME = "empty_config"; final String CFG_NAME = "empty_config";
@ -673,6 +682,7 @@ public class RefreshScopeTests extends TestCase {
} }
@Test
public void testNullProjectDescription_bug387428() { public void testNullProjectDescription_bug387428() {
final String CFG_NAME = "empty_config"; final String CFG_NAME = "empty_config";
@ -688,8 +698,4 @@ public class RefreshScopeTests extends TestCase {
assertEquals(true, empty_config_resources.contains(fGeneralProject)); assertEquals(true, empty_config_resources.contains(fGeneralProject));
} }
public static Test suite() {
return new TestSuite(RefreshScopeTests.class);
}
} }