Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJonah Graham2020-12-21 20:22:55 +0000
committerJonah Graham2021-02-01 16:32:58 +0000
commit64e21a93c46623fb0f641fd25d0e537cc10f52a7 (patch)
tree1db1772521d78b561a4c670f57fef026793d7805 /core
parent5c82be881d09ca8df67d334934554c4df3b7f199 (diff)
downloadorg.eclipse.cdt-64e21a93c46623fb0f641fd25d0e537cc10f52a7.tar.gz
org.eclipse.cdt-64e21a93c46623fb0f641fd25d0e537cc10f52a7.tar.xz
org.eclipse.cdt-64e21a93c46623fb0f641fd25d0e537cc10f52a7.zip
Bug 499777: Flaky and slow test tags
to exclude flaky and slow tests from gerrit runs and main build tests can be tagged as such. See BTreeExpensiveTests for example of a slow test and Bug_303953Test for an example of a flaky one. The root README.md has a few notes on converting tests to JUnit5 and adding annotations to mark them slow or flaky. Change-Id: I03a4004112e6a500d8ec2771d68f14f7dc5f67fb
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java151
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/AllLanguageSettingsProvidersCoreTestSuite.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java97
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java19
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java19
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestSuite.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java3
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase5.java25
8 files changed, 175 insertions, 143 deletions
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java
index 8c8b42f6f05..472d3650315 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/cdescriptor/tests/CDescriptorTests.java
@@ -16,6 +16,12 @@
***********************************************************************/
package org.eclipse.cdt.core.cdescriptor.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.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -32,7 +38,7 @@ import org.eclipse.cdt.core.ICOwnerInfo;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
-import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
+import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -42,33 +48,20 @@ import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.junit.Assert;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-public class CDescriptorTests extends BaseTestCase {
+@Tag(BaseTestCase5.FLAKY_TEST_TAG)
+public class CDescriptorTests extends BaseTestCase5 {
static String projectId = CTestPlugin.PLUGIN_ID + ".TestProject";
static IProject fProject;
static CDescriptorListener listener = new CDescriptorListener();
static volatile CDescriptorEvent fLastEvent;
- /**
- * Constructor for CDescriptorTest.
- *
- * @param name
- */
- public CDescriptorTests(String name) {
- super(name);
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite(CDescriptorTests.class);
- return suite;
- }
-
- @Override
- protected void setUp() throws Exception {
+ @BeforeEach
+ protected void setUpLocal() throws Exception {
CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
@@ -97,8 +90,8 @@ public class CDescriptorTests extends BaseTestCase {
}, null);
}
- @Override
- protected void tearDown() throws Exception {
+ @AfterEach
+ protected void tearDownLocal() throws Exception {
fProject.delete(true, true, null);
}
@@ -120,29 +113,32 @@ public class CDescriptorTests extends BaseTestCase {
}
}
+ @Test
public void testDescriptorCreation() throws Exception {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
- Assert.assertNotNull(fLastEvent);
- Assert.assertEquals(fLastEvent.getDescriptor(), desc);
- Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_ADDED);
- Assert.assertEquals(fLastEvent.getFlags(), 0);
+ assertNotNull(fLastEvent);
+ assertEquals(fLastEvent.getDescriptor(), desc);
+ assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_ADDED);
+ assertEquals(fLastEvent.getFlags(), 0);
fLastEvent = null;
- Assert.assertEquals(fProject, desc.getProject());
- Assert.assertEquals("*", desc.getPlatform());
+ assertEquals(fProject, desc.getProject());
+ assertEquals("*", desc.getPlatform());
}
+ @Test
public void testDescriptorOwner() throws Exception {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
ICOwnerInfo owner = desc.getProjectOwner();
- Assert.assertEquals(projectId, owner.getID());
- Assert.assertEquals("*", owner.getPlatform());
- Assert.assertEquals("C/C++ Test Project", owner.getName());
+ assertEquals(projectId, owner.getID());
+ assertEquals("*", owner.getPlatform());
+ assertEquals("C/C++ Test Project", owner.getName());
}
// Disabled this test because it fails every now and then and it tests deprecated API
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340123
+ // @Test
public void _testConcurrentDescriptorCreation() throws Exception {
for (int i = 0; i < 100; i++) {
fProject.close(null);
@@ -179,6 +175,7 @@ public class CDescriptorTests extends BaseTestCase {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185930
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=193503
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=196118
+ @Test
public void testConcurrentDescriptorModification() throws Exception {
int lastLength = 0;
for (int i = 0; i < 100; ++i) {
@@ -230,12 +227,12 @@ public class CDescriptorTests extends BaseTestCase {
} catch (InterruptedException e) {
}
}
- assertNull("Exception occurred: " + exception[j], exception[j]);
+ assertNull(exception[j], "Exception occurred: " + exception[j]);
}
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
int lengthAfter = desc.getProjectStorageElement("testElement").getChildren().length;
lastLength += threads.length; // Update last lengths to what we expect
- assertEquals("Iteration count: " + i, lastLength, lengthAfter);
+ assertEquals(lastLength, lengthAfter, "Iteration count: " + i);
fLastEvent = null;
}
@@ -245,6 +242,7 @@ public class CDescriptorTests extends BaseTestCase {
* This test should pass as two threads, operating on the different storage elements
* (outside of an operation) should be safe.
*/
+ @Test
public void testConcurrentDifferentStorageElementModification() throws Exception {
for (int i = 0; i < 100; ++i) {
Thread t = new Thread() {
@@ -273,15 +271,16 @@ public class CDescriptorTests extends BaseTestCase {
fLastEvent = null;
}
- Assert.assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
+ assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
.getProjectStorageElement("testElement4").getChildren().length);
- Assert.assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
+ assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
.getProjectStorageElement("testElement5").getChildren().length);
}
/*
* Tests that (non-structural) changes to the storage element tree work as expected.
*/
+ @Test
public void testConcurrentSameStorageElementModification() throws Exception {
for (int i = 0; i < 100; ++i) {
Thread t = new Thread() {
@@ -310,17 +309,18 @@ public class CDescriptorTests extends BaseTestCase {
fLastEvent = null;
}
- Assert.assertEquals(200, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
+ assertEquals(200, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
.getProjectStorageElement("testElement6").getChildren().length);
}
/*
* Tests deadlock when accessing c project description concurrently from two threads
*/
+ @Test
public void testDeadlockDuringProjectCreation() throws Exception {
for (int i = 0; i < 10; ++i) {
- tearDown();
- setUp();
+ tearDownLocal();
+ setUpLocal();
Thread t = new Thread() {
@Override
public void run() {
@@ -348,33 +348,37 @@ public class CDescriptorTests extends BaseTestCase {
}
}
+ @Test
public void testDescriptorConversion() {
}
+ @Test
public void testExtensionCreation() throws Exception {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
ICExtensionReference extRef = desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
- Assert.assertNotNull(fLastEvent);
- Assert.assertEquals(fLastEvent.getDescriptor(), desc);
- Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
- Assert.assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED);
+ assertNotNull(fLastEvent);
+ assertEquals(fLastEvent.getDescriptor(), desc);
+ assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
+ assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED);
fLastEvent = null;
- Assert.assertEquals("org.eclipse.cdt.testextension", extRef.getExtension());
- Assert.assertEquals("org.eclipse.cdt.testextensionID", extRef.getID());
+ assertEquals("org.eclipse.cdt.testextension", extRef.getExtension());
+ assertEquals("org.eclipse.cdt.testextensionID", extRef.getID());
}
+ @Test
public void testExtensionGet() throws Exception {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
ICExtensionReference extRef[] = desc.get("org.eclipse.cdt.testextension");
- Assert.assertEquals("org.eclipse.cdt.testextension", extRef[0].getExtension());
- Assert.assertEquals("org.eclipse.cdt.testextensionID", extRef[0].getID());
+ assertEquals("org.eclipse.cdt.testextension", extRef[0].getExtension());
+ assertEquals("org.eclipse.cdt.testextensionID", extRef[0].getID());
}
+ @Test
public void testExtensionData() throws Exception {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
@@ -382,17 +386,18 @@ public class CDescriptorTests extends BaseTestCase {
ICExtensionReference extRef[] = desc.get("org.eclipse.cdt.testextension");
extRef[0].setExtensionData("testKey", "testValue");
- Assert.assertNotNull(fLastEvent);
- Assert.assertEquals(fLastEvent.getDescriptor(), desc);
- Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
- Assert.assertEquals(fLastEvent.getFlags(), 0);
+ assertNotNull(fLastEvent);
+ assertEquals(fLastEvent.getDescriptor(), desc);
+ assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
+ assertEquals(fLastEvent.getFlags(), 0);
fLastEvent = null;
- Assert.assertEquals("testValue", extRef[0].getExtensionData("testKey"));
+ assertEquals("testValue", extRef[0].getExtensionData("testKey"));
extRef[0].setExtensionData("testKey", null);
- Assert.assertEquals(null, extRef[0].getExtensionData("testKey"));
+ assertEquals(null, extRef[0].getExtensionData("testKey"));
}
+ @Test
public void testExtensionRemove() throws Exception {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
@@ -400,43 +405,46 @@ public class CDescriptorTests extends BaseTestCase {
ICExtensionReference extRef[] = desc.get("org.eclipse.cdt.testextension");
desc.remove(extRef[0]);
- Assert.assertNotNull(fLastEvent);
- Assert.assertEquals(fLastEvent.getDescriptor(), desc);
- Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
- Assert.assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED);
+ assertNotNull(fLastEvent);
+ assertEquals(fLastEvent.getDescriptor(), desc);
+ assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
+ assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED);
fLastEvent = null;
}
+ @Test
public void testProjectDataCreate() throws Exception {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
ICStorageElement data = desc.getProjectStorageElement("testElement");
data.createChild("test");
desc.saveProjectData();
- Assert.assertNotNull(fLastEvent);
- Assert.assertEquals(fLastEvent.getDescriptor(), desc);
- Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
- Assert.assertEquals(fLastEvent.getFlags(), 0);
+ assertNotNull(fLastEvent);
+ assertEquals(fLastEvent.getDescriptor(), desc);
+ assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
+ assertEquals(fLastEvent.getFlags(), 0);
fLastEvent = null;
}
+ @Test
public void testProjectDataDelete() throws Exception {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
ICStorageElement data = desc.getProjectStorageElement("testElement");
data.createChild("test");
ICStorageElement[] list = data.getChildrenByName("test");
- Assert.assertEquals(1, list.length);
+ assertEquals(1, list.length);
data.removeChild(list[0]);
desc.saveProjectData();
- Assert.assertNotNull(fLastEvent);
- Assert.assertEquals(fLastEvent.getDescriptor(), desc);
- Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
- Assert.assertEquals(fLastEvent.getFlags(), 0);
+ assertNotNull(fLastEvent);
+ assertEquals(fLastEvent.getDescriptor(), desc);
+ assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
+ assertEquals(fLastEvent.getFlags(), 0);
fLastEvent = null;
}
+ @Test
public void testCProjectDescriptionDescriptorInteraction() throws Exception {
for (int i = 1; i < 100; i++) {
// Create a descriptor with some test data
@@ -469,6 +477,7 @@ public class CDescriptorTests extends BaseTestCase {
}
}
+ @Test
public void testAccumulatingBlankLinesInProjectData() throws Exception {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
ICStorageElement data = desc.getProjectStorageElement("testElement");
@@ -491,8 +500,8 @@ public class CDescriptorTests extends BaseTestCase {
String dotCProject2 = readDotCProjectFile(fProject);
long mtime2 = fProject.getFile(".cproject").getLocalTimeStamp();
- assertEquals("Difference in .cproject file", dotCProject1, dotCProject2);
- assertTrue(".cproject file has been written", mtime1 == mtime2);
+ assertEquals(dotCProject1, dotCProject2, "Difference in .cproject file");
+ assertTrue(mtime1 == mtime2, ".cproject file has been written");
// do it a second time - just to be sure
fProject.close(null);
@@ -508,8 +517,8 @@ public class CDescriptorTests extends BaseTestCase {
String dotCProject3 = readDotCProjectFile(fProject);
long mtime3 = fProject.getFile(".cproject").getLocalTimeStamp();
- assertEquals("Difference in .cproject file", dotCProject2, dotCProject3);
- assertTrue(".cproject file has been written", mtime2 == mtime3);
+ assertEquals(dotCProject2, dotCProject3, "Difference in .cproject file");
+ assertTrue(mtime2 == mtime3, ".cproject file has been written");
}
/**
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/AllLanguageSettingsProvidersCoreTestSuite.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/AllLanguageSettingsProvidersCoreTestSuite.java
index 412b11440c2..e8c6498023e 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/AllLanguageSettingsProvidersCoreTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/AllLanguageSettingsProvidersCoreTestSuite.java
@@ -32,7 +32,7 @@ public class AllLanguageSettingsProvidersCoreTestSuite {
suite.addTest(LanguageSettingsExtensionsTests.suite());
suite.addTest(LanguageSettingsManagerTests.suite());
suite.addTest(LanguageSettingsSerializableProviderTests.suite());
- suite.addTest(LanguageSettingsPersistenceProjectTests.suite());
+ // Test converted to JUnit5: suite.addTest(LanguageSettingsPersistenceProjectTests.suite());
suite.addTest(LanguageSettingsListenersTests.suite());
suite.addTest(LanguageSettingsScannerInfoProviderTests.suite());
suite.addTest(LanguageSettingsProviderReferencedProjectsTests.suite());
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java
index 9ff5fd507b6..c2825c761d9 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 Andrew Gvozdev and others.
+ * Copyright (c) 2009, 2020 Andrew Gvozdev and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,6 +14,13 @@
package org.eclipse.cdt.core.language.settings.providers;
+import static org.junit.Assert.assertNull;
+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.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -26,7 +33,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.WriteAccessException;
import org.eclipse.cdt.core.testplugin.CModelMock;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
-import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
+import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
import org.eclipse.cdt.internal.core.XmlUtil;
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
@@ -34,15 +41,16 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import junit.framework.TestSuite;
-
/**
* Test cases testing LanguageSettingsProvider functionality related to persistence.
*/
-public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
+public class LanguageSettingsPersistenceProjectTests extends BaseTestCase5 {
// These should match extension points defined in plugin.xml
private static final String EXTENSION_BASE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_ID;
private static final String EXTENSION_BASE_PROVIDER_NAME = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_NAME;
@@ -130,39 +138,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
}
}
- /**
- * Constructor.
- * @param name - name of the test.
- */
- public LanguageSettingsPersistenceProjectTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
+ @AfterEach
+ protected void tearDownLocal() throws Exception {
LanguageSettingsManager.setWorkspaceProviders(null);
- super.tearDown(); // includes ResourceHelper cleanup
- }
-
- /**
- * @return - new TestSuite.
- */
- public static TestSuite suite() {
- return new TestSuite(LanguageSettingsPersistenceProjectTests.class);
- }
-
- /**
- * main function of the class.
- *
- * @param args - arguments
- */
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
}
/**
@@ -195,6 +173,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Persist and reload when no customized providers are defined in the workspace.
*/
+ @Test
public void testWorkspacePersistence_NoProviders() throws Exception {
// serialize language settings of user defined providers (on workspace level)
LanguageSettingsProvidersSerializer.serializeLanguageSettingsWorkspace();
@@ -206,6 +185,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Make sure providers in configuration cannot be modified accidentally outside of API.
*/
+ @Test
public void testProjectDescription_PreventBackDoorAccess() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
@@ -239,6 +219,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test assigning providers to read-only vs. writable configuration descriptions.
*/
+ @Test
public void testProjectDescription_ReadWriteDescription() throws Exception {
// create a project
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
@@ -367,6 +348,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Persist and reload a customized provider defined in the workspace.
*/
+ @Test
public void testWorkspacePersistence_ModifiedExtensionProvider() throws Exception {
List<ICLanguageSettingEntry> entries = new ArrayList<>();
entries.add(new CIncludePathEntry("path0", 0));
@@ -416,6 +398,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Check persistence of unmodified extension provider in the workspace.
*/
+ @Test
public void testWorkspacePersistence_UnmodifiedExtensionProvider() throws Exception {
List<ICLanguageSettingEntry> extensionEntries = new ArrayList<>();
extensionEntries.add(EXTENSION_SERIALIZABLE_PROVIDER_ENTRY);
@@ -463,6 +446,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test persistence of global providers in the workspace.
*/
+ @Test
public void testWorkspacePersistence_GlobalProvider() throws Exception {
{
// get the raw extension provider
@@ -498,6 +482,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test persistence of global providers with ID matching an extension provider in the workspace.
*/
+ @Test
public void testWorkspacePersistence_ShadowedExtensionProvider() throws Exception {
{
// get the raw extension provider
@@ -569,6 +554,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test serialization of providers to project storage.
*/
+ @Test
public void testProjectPersistence_SerializableProviderDOM() throws Exception {
Element rootElement = null;
@@ -631,6 +617,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test User language settings provider defined as extension in cdt.ui.
*/
+ @Test
public void testProjectPersistence_UserProviderDOM() throws Exception {
Element rootElement = null;
@@ -695,6 +682,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test serialization of providers to project storage where the project has multiple configurations.
*/
+ @Test
public void testProjectPersistence_TwoConfigurationsDOM() throws Exception {
Element rootElement = null;
@@ -837,6 +825,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test serialization of providers subclassing {@link LanguageSettingsSerializableProvider}.
*/
+ @Test
public void testProjectPersistence_SubclassedSerializableProviderDOM() throws Exception {
Element rootElement = null;
@@ -898,6 +887,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Serialization of providers exactly equal extension providers.
*/
+ @Test
public void testProjectPersistence_ReferenceExtensionProviderDOM() throws Exception {
Element rootElement = null;
@@ -953,6 +943,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test serialization of providers overriding/shadowing extension providers.
*/
+ @Test
public void testProjectPersistence_OverrideExtensionProviderDOM() throws Exception {
Element rootElement = null;
@@ -1013,6 +1004,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test serialization flavors in one storage.
*/
+ @Test
public void testProjectPersistence_MixedProvidersDOM() throws Exception {
Element rootElement = null;
@@ -1107,6 +1099,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test serialization of real project.
*/
+ @Test
public void testProjectPersistence_RealProject() throws Exception {
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFile xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
@@ -1224,17 +1217,17 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
String xmlStorageFileLocation = xmlStorageFilePrj.getLocation().toOSString();
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
xmlFile.delete();
- assertFalse("File " + xmlFile + " still exist", xmlFile.exists());
+ assertNotExists(xmlFile);
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
xmlFileOut.renameTo(xmlFile);
- assertTrue("File " + xmlFile + " does not exist", xmlFile.exists());
- assertFalse("File " + xmlFileOut + " still exist", xmlFileOut.exists());
+ assertExists(xmlFile);
+ assertNotExists(xmlFileOut);
// Wait out in case indexer thread hijacks refreshLocal(), see bug 415970
waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project));
// Refresh storage in workspace
xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null);
- assertTrue("File " + xmlStorageFilePrj + " does not exist", xmlStorageFilePrj.exists());
+ assertExists(xmlStorageFilePrj);
// and close
project.close(null);
@@ -1266,6 +1259,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test case when the storage is split between project and workspace area.
*/
+ @Test
public void testProjectPersistence_SplitStorageDOM() throws Exception {
Element prjStorageElement = null;
Element wspStorageElement = null;
@@ -1343,6 +1337,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test split storage in a real project.
*/
+ @Test
public void testProjectPersistence_RealProjectSplitStorage() throws Exception {
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFile xmlStorageFilePrj;
@@ -1472,17 +1467,17 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
String xmlStorageFilePrjLocation = xmlStorageFilePrj.getLocation().toOSString();
java.io.File xmlFile = new java.io.File(xmlStorageFilePrjLocation);
xmlFile.delete();
- assertFalse("File " + xmlFile + " still exist", xmlFile.exists());
+ assertNotExists(xmlFile);
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
xmlFileOut.renameTo(xmlFile);
- assertTrue("File " + xmlFile + " does not exist", xmlFile.exists());
- assertFalse("File " + xmlFileOut + " still exist", xmlFileOut.exists());
+ assertExists(xmlFile);
+ assertNotExists(xmlFileOut);
// Wait out in case indexer thread hijacks refreshLocal(), see bug 415970
waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project));
// Refresh storage in workspace
xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null);
- assertTrue("File " + xmlStorageFilePrj + " does not exist", xmlStorageFilePrj.exists());
+ assertExists(xmlStorageFilePrj);
// and close
project.close(null);
@@ -1492,11 +1487,11 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
// Move workspace storage back
java.io.File xmlWspFile = new java.io.File(xmlStorageFileWspLocation);
xmlWspFile.delete();
- assertFalse("File " + xmlWspFile + " still exist", xmlWspFile.exists());
+ assertNotExists(xmlWspFile);
java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay);
xmlWspFileOut.renameTo(xmlWspFile);
- assertTrue("File " + xmlWspFile + " does not exist", xmlWspFile.exists());
- assertFalse("File " + xmlWspFileOut + " still exist", xmlWspFileOut.exists());
+ assertExists(xmlWspFile);
+ assertNotExists(xmlWspFileOut);
}
{
@@ -1525,6 +1520,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test serialization of providers referring to global shared instance.
*/
+ @Test
public void testProjectPersistence_ProviderExtensionReferenceDOM() throws Exception {
Document doc = XmlUtil.newDocument();
Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST);
@@ -1582,6 +1578,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Walk the scenario when a provider is cloned to a configuration from extension.
*/
+ @Test
public void testProjectPersistence_ProviderExtensionCopyDOM() throws Exception {
Document doc = XmlUtil.newDocument();
Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST);
@@ -1639,6 +1636,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test that default settings do not cause the files to appear in the project or file-system.
*/
+ @Test
public void testProjectPersistence_Defaults() throws Exception {
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
IFile xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
@@ -1653,6 +1651,8 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test serialization of global providers exactly equal extension in workspace area.
*/
+ @Test
+ @Tag(FLAKY_TEST_TAG)
public void testWorkspacePersistence_ProviderExtensionCopy() throws Exception {
List<ICLanguageSettingEntry> entries = new ArrayList<>();
List<ILanguageSettingsProvider> providers = new ArrayList<>();
@@ -1698,6 +1698,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
/**
* Test that default settings do not cause the file to appear on the file-system.
*/
+ @Test
public void testWorkspacePersistence_Defaults() throws Exception {
// reset and serialize workspace providers
LanguageSettingsManager.setWorkspaceProviders(null);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java
index 6243210c693..cc937ccaa4d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeExpensiveTests.java
@@ -13,7 +13,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests;
-import junit.framework.Test;
+import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Tests which are too expensive to run as part of normal testing, but
@@ -23,36 +25,31 @@ import junit.framework.Test;
* invariants after each B-tree operation, and so are especially
* expensive and cpu hungry.
*/
+@Tag(BaseTestCase5.SLOW_TEST_TAG)
public class BTreeExpensiveTests extends BTreeTests {
- public static Test suite() {
- return suite(BTreeExpensiveTests.class);
- }
-
+ @Test
public void testBySortedSetMirror() throws Exception {
sortedMirrorTest(100);
}
- // @Override
- @Override
- public void testInsertion() throws Exception {
- super.testInsertion();
- }
-
/*
* N.B. Each of the following tests are quite expensive (i.e. > 10mins each on a 2Ghz machine)
*/
+ @Test
public void testBySortedSetMirror1682762087() throws Exception {
System.out.println("1682762087 Full Checking");
trial(1682762087, true); // exposed bugs in 2a,b
}
+ @Test
public void testBySortedSetMirror322922974() throws Exception {
System.out.println("322922974 Full Checking");
trial(322922974, true); // exposed bugs in 3b(ii)
}
+ @Test
public void testBySortedSetMirror_588448152() throws Exception {
System.out.println("-588448152 Full Checking");
trial(-588448152, true); // exposed root-delete-on-merge problems
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java
index 85ccc104029..cdf508afccc 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/BTreeTests.java
@@ -14,6 +14,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
@@ -22,22 +25,21 @@ import java.util.Random;
import java.util.SortedSet;
import java.util.TreeSet;
-import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
+import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.db.ChunkCache;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
import org.eclipse.core.runtime.CoreException;
-
-import junit.framework.Test;
+import org.junit.jupiter.api.Test;
/**
* Test insertion/deletion of records of a mock record type in a B-tree.
*
* @author aferguso
*/
-public class BTreeTests extends BaseTestCase {
+public class BTreeTests extends BaseTestCase5 {
private static int DEBUG = 0;
protected File dbFile;
protected Database db;
@@ -45,10 +47,6 @@ public class BTreeTests extends BaseTestCase {
protected int rootRecord;
protected IBTreeComparator comparator;
- public static Test suite() {
- return suite(BTreeTests.class);
- }
-
// setUp is not used since we need to parameterize this method,
// and invoke it multiple times per Junit test
protected void init(int degree) throws Exception {
@@ -66,6 +64,7 @@ public class BTreeTests extends BaseTestCase {
dbFile.deleteOnExit();
}
+ @Test
public void testBySortedSetMirrorLite() throws Exception {
sortedMirrorTest(8);
}
@@ -91,6 +90,7 @@ public class BTreeTests extends BaseTestCase {
* and use TreeSet as a reference implementation to check behaviour against.
* @throws Exception
*/
+ @Test
public void testInsertion() throws Exception {
Random seeder = new Random();
@@ -105,6 +105,7 @@ public class BTreeTests extends BaseTestCase {
/**
* Bug 402177: BTree.insert should return the matching record if the new record was not inserted.
*/
+ @Test
public void testEquivalentRecordInsert_Bug402177() throws Exception {
init(8);
try {
@@ -208,7 +209,7 @@ public class BTreeTests extends BaseTestCase {
BTMockRecord btValue = new BTMockRecord(record, db);
if (i.hasNext()) {
Integer exp = ((Integer) i.next());
- assertEquals(msg + " Differ at index: " + k, btValue.intValue(), exp.intValue());
+ assertEquals(btValue.intValue(), exp.intValue(), msg + " Differ at index: " + k);
k++;
} else {
fail("Sizes different");
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestSuite.java
index c3f70a8a69f..a751b64317f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestSuite.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTestSuite.java
@@ -43,7 +43,7 @@ public class PDOMTestSuite extends TestSuite {
suite.addTest(IncludesTests.suite());
suite.addTest(OverloadsWithinSingleTUTests.suite());
suite.addTest(OverloadsWithinCommonHeaderTests.suite());
- suite.addTest(BTreeTests.suite());
+ // Test converted to JUnit5: suite.addTest(BTreeTests.suite());
suite.addTest(PDOMStringSetTests.suite());
suite.addTest(PDOMTagIndexTests.suite());
suite.addTest(FilesOnReindexTests.suite());
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java
index df36f5a693e..c6e0b263bb1 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java
@@ -17,7 +17,6 @@
package org.eclipse.cdt.core.suite;
import org.eclipse.cdt.core.cdescriptor.tests.CDescriptorOldTests;
-import org.eclipse.cdt.core.cdescriptor.tests.CDescriptorTests;
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManagerTests;
import org.eclipse.cdt.core.internal.efsextension.tests.EFSExtensionTests;
import org.eclipse.cdt.core.internal.errorparsers.tests.ErrorParserTestSuite;
@@ -77,7 +76,7 @@ public class AutomatedIntegrationSuite extends TestSuite {
// Has intermittent failures
if (System.getProperty("cdt.skip.known.test.failures") == null) {
- suite.addTest(CDescriptorTests.suite());
+ // Test converted to JUnit5: suite.addTest(CDescriptorTests.suite());
}
suite.addTest(AllConstexprEvalTestSuite.suite());
suite.addTest(ParserTestSuite.suite());
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase5.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase5.java
index 8f9c529924f..d486ac35829 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase5.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase5.java
@@ -43,14 +43,30 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.TestInfo;
+import junit.framework.Test;
import junit.framework.TestResult;
/**
* BaseTestCase for JUnit5.
*/
public abstract class BaseTestCase5 {
+ /**
+ * Bug 499777: Numerous tests are flaky and of little value on gerrit verification builds. This
+ * tag can be applied to JUnit5 tests with the {@link Tag} annotation to skip flaky tests in
+ * such circumstances.
+ */
+ public static final String FLAKY_TEST_TAG = "flakyTest";
+
+ /**
+ * Bug 499777: Numerous tests are very slow and of little value on gerrit verification builds. This
+ * tag can be applied to JUnit5 tests with the {@link Tag} annotation to skip slow tests in
+ * such circumstances.
+ */
+ public static final String SLOW_TEST_TAG = "slowTest";
+
protected static final String DEFAULT_INDEXER_TIMEOUT_SEC = "10";
protected static final String INDEXER_TIMEOUT_PROPERTY = "indexer.timeout";
/**
@@ -245,6 +261,15 @@ public abstract class BaseTestCase5 {
* This method is declared as final to help transition to JUnit5 to ensure that
* accidental override of the method is not left in subclasses when migrating.
*/
+ final protected static Test suite() {
+ fail("Test not migrated properly to JUnit5 yet.");
+ return null; // unreachable
+ }
+
+ /**
+ * This method is declared as final to help transition to JUnit5 to ensure that
+ * accidental override of the method is not left in subclasses when migrating.
+ */
final protected void tearDown() {
fail("Test not migrated properly to JUnit5 yet.");
}

Back to the top