mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
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
This commit is contained in:
parent
5c82be881d
commit
64e21a93c4
16 changed files with 281 additions and 213 deletions
26
README.md
26
README.md
|
@ -98,6 +98,16 @@ with `-DskipDoc=true`
|
||||||
Running tests for CDT can be time consuming. For local builds this can be skipped
|
Running tests for CDT can be time consuming. For local builds this can be skipped
|
||||||
with `-DskipTests=true`.
|
with `-DskipTests=true`.
|
||||||
|
|
||||||
|
#### excludedGroups to skip slow or flaky tests
|
||||||
|
|
||||||
|
Some tests in CDT are fairly slow to run and rarely are exercising actively changing code. Some tests in CDT are fairly flaky to run and rarely are exercising actively changing code. These tests are excluded from the main CDT builds (both master/branch and gerrit verify jobs) and are instead run in a special job. Therefore the Jenkinsfiles for master/branch and gerrit use excludedGroups by default.
|
||||||
|
|
||||||
|
To skip slow tests use `-DexcludedGroups=slowTest`
|
||||||
|
To skip flaky tests use `-DexcludedGroups=flakyTest`
|
||||||
|
To skip both use `-DexcludedGroups=flakyTest,slowTest`
|
||||||
|
|
||||||
|
See section below on marking tests for how to annotate a test properly.
|
||||||
|
|
||||||
#### jgit.dirtyWorkingTree-cdtDefault
|
#### jgit.dirtyWorkingTree-cdtDefault
|
||||||
|
|
||||||
Running a build with uncommitted changes will normally cause an error. To run a build with
|
Running a build with uncommitted changes will normally cause an error. To run a build with
|
||||||
|
@ -147,3 +157,19 @@ When the host is Windows, getting docker to behave as encoded in the pom.xml may
|
||||||
|
|
||||||
See also `jniheaders` profile above.
|
See also `jniheaders` profile above.
|
||||||
|
|
||||||
|
### Marking tests as Slow or Flaky
|
||||||
|
|
||||||
|
Tests in CDT can be marked as Slow or Flaky to prevent them running as part of the standard test suites. See excludedGroups to skip slow or flaky tests sections above.
|
||||||
|
|
||||||
|
The proper way to mark a test as slow or flaky is to add a JUnit5 @Tag on the test with `flakyTest` or `slowTest`. The canonical values for these are in the JUnit5 base test `org.eclipse.cdt.core.testplugin.util.BaseTestCase5`.
|
||||||
|
|
||||||
|
These tags can only be applied to JUnit5 (aka Jupiter) tests. If a test needs converting, do that in a separate commit before adding the tags so that the test refactoring can be verified before excluding the test from normal runs.
|
||||||
|
|
||||||
|
### Converting tests to JUnit5
|
||||||
|
|
||||||
|
To take advantage of new features, such as excluding flaky and slow tests, individual tests need to JUnit5 (aka Jupiter). If a test is currently written in JUnit4 or JUnit3 style it needs to be converted to JUnit5 first. Those tests that currently derive from `org.eclipse.cdt.core.testplugin.util.BaseTestCase` can change to `org.eclipse.cdt.core.testplugin.util.BaseTestCase5` and make further adjustments. Common adjustments are:
|
||||||
|
- refactoring `setUp`/`tearDown` methods to use `@BeforeEach` and `@AfterEach` annotations
|
||||||
|
- refactor complicated uses of TestSuites in JUnit3 that were workarounds for the lack of JUnit features like `@BeforeAll` and `@AfterAll`.
|
||||||
|
- add `@Test` annotation (make sure to use `org.junit.jupiter.api.Test` and not JUnit4's `org.junit.Test`)
|
||||||
|
- statically import assert methods from `org.junit.jupiter.api.Assertions` (note that in JUnit5 the message is now last instead of first, this generally leads to an error by changing the imports, except in the case of `assertEquals` where the first and third parameter are `String`)
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.managedbuilder.testplugin;
|
package org.eclipse.cdt.managedbuilder.testplugin;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -42,8 +45,9 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import junit.framework.TestCase;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.TestInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract builder test which provides utility methods for:
|
* Abstract builder test which provides utility methods for:
|
||||||
|
@ -55,7 +59,7 @@ import junit.framework.TestCase;
|
||||||
* <li>Cleaning up the workspace at the end</li>
|
* <li>Cleaning up the workspace at the end</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractBuilderTest extends TestCase {
|
public abstract class AbstractBuilderTest {
|
||||||
private static final boolean WINDOWS = java.io.File.separatorChar == '\\';
|
private static final boolean WINDOWS = java.io.File.separatorChar == '\\';
|
||||||
|
|
||||||
static final String PATH = "builderTests";
|
static final String PATH = "builderTests";
|
||||||
|
@ -63,16 +67,14 @@ public abstract class AbstractBuilderTest extends TestCase {
|
||||||
private String workspace;
|
private String workspace;
|
||||||
private List<IProject> projects;
|
private List<IProject> projects;
|
||||||
|
|
||||||
@Override
|
@BeforeEach
|
||||||
protected void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
|
||||||
setAutoBuilding(false);
|
setAutoBuilding(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@AfterEach
|
||||||
protected void tearDown() throws Exception {
|
public void tearDown(TestInfo testInfo) throws Exception {
|
||||||
super.tearDown();
|
ResourceHelper.cleanUp(testInfo.getDisplayName());
|
||||||
ResourceHelper.cleanUp(getName());
|
|
||||||
// Bug 327126 Stop the indexer before tearing down so we don't deadlock
|
// Bug 327126 Stop the indexer before tearing down so we don't deadlock
|
||||||
Job.getJobManager().cancel(CCorePlugin.getPDOMManager());
|
Job.getJobManager().cancel(CCorePlugin.getPDOMManager());
|
||||||
Job.getJobManager().join(CCorePlugin.getPDOMManager(), null);
|
Job.getJobManager().join(CCorePlugin.getPDOMManager(), null);
|
||||||
|
@ -113,7 +115,7 @@ public abstract class AbstractBuilderTest extends TestCase {
|
||||||
};
|
};
|
||||||
getWorkspace().run(body, null);
|
getWorkspace().run(body, null);
|
||||||
} finally {
|
} finally {
|
||||||
assertTrue(verifier.getMessage(), verifier.isDeltaValid());
|
assertTrue(verifier.isDeltaValid(), verifier.getMessage());
|
||||||
getWorkspace().removeResourceChangeListener(verifier);
|
getWorkspace().removeResourceChangeListener(verifier);
|
||||||
printAllMarkers();
|
printAllMarkers();
|
||||||
}
|
}
|
||||||
|
@ -240,14 +242,6 @@ public abstract class AbstractBuilderTest extends TestCase {
|
||||||
return resources;
|
return resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractBuilderTest() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public AbstractBuilderTest(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setWorkspace(String name) {
|
protected void setWorkspace(String name) {
|
||||||
workspace = name;
|
workspace = name;
|
||||||
projects = new ArrayList<>();
|
projects = new ArrayList<>();
|
||||||
|
|
|
@ -22,11 +22,10 @@ import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.regressions.RegressionTestSuite;
|
import org.eclipse.cdt.managedbuilder.core.regressions.RegressionTestSuite;
|
||||||
import org.eclipse.cdt.managedbuilder.core.tests.BuildDescriptionModelTests;
|
import org.eclipse.cdt.managedbuilder.core.tests.BuildDescriptionModelTests;
|
||||||
import org.eclipse.cdt.managedbuilder.core.tests.BuildSystem40Tests;
|
import org.eclipse.cdt.managedbuilder.core.tests.BuildSystem40Tests;
|
||||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCore20Tests;
|
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCore20Tests;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests;
|
||||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCore_SharedToolOptionsTests;
|
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCore_SharedToolOptionsTests;
|
||||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildDependencyCalculatorTests;
|
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildDependencyCalculatorTests;
|
||||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildDependencyLibsTests;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildEnvironmentTests;
|
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildEnvironmentTests;
|
||||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildMacrosTests;
|
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildMacrosTests;
|
||||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildTCSupportedTest;
|
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildTCSupportedTest;
|
||||||
|
@ -74,7 +73,7 @@ public class AutomatedIntegrationSuite {
|
||||||
suite.addTest(AllLanguageSettingsProvidersMBSTestSuite.suite());
|
suite.addTest(AllLanguageSettingsProvidersMBSTestSuite.suite());
|
||||||
|
|
||||||
// managedbuilder.core.tests
|
// managedbuilder.core.tests
|
||||||
suite.addTest(ManagedBuildDependencyLibsTests.suite());
|
// Test converted to JUnit5: suite.addTest(ManagedBuildDependencyLibsTests.suite());
|
||||||
suite.addTest(ManagedBuildCore20Tests.suite());
|
suite.addTest(ManagedBuildCore20Tests.suite());
|
||||||
suite.addTest(ManagedBuildCoreTests.suite());
|
suite.addTest(ManagedBuildCoreTests.suite());
|
||||||
suite.addTest(ManagedProjectUpdateTests.suite());
|
suite.addTest(ManagedProjectUpdateTests.suite());
|
||||||
|
|
|
@ -13,11 +13,14 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.core.regressions;
|
package org.eclipse.cdt.managedbuilder.core.regressions;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase5;
|
||||||
import org.eclipse.cdt.managedbuilder.testplugin.AbstractBuilderTest;
|
import org.eclipse.cdt.managedbuilder.testplugin.AbstractBuilderTest;
|
||||||
import org.eclipse.cdt.managedbuilder.testplugin.ResourceDeltaVerifier;
|
import org.eclipse.cdt.managedbuilder.testplugin.ResourceDeltaVerifier;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -26,6 +29,8 @@ import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that removing the last source file from a directory
|
* Tests that removing the last source file from a directory
|
||||||
|
@ -34,6 +39,8 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*/
|
*/
|
||||||
public class Bug_303953Test extends AbstractBuilderTest {
|
public class Bug_303953Test extends AbstractBuilderTest {
|
||||||
|
|
||||||
|
@Tag(BaseTestCase5.FLAKY_TEST_TAG)
|
||||||
|
@Test
|
||||||
public void testBuildAfterSourcefileDelete() throws CoreException {
|
public void testBuildAfterSourcefileDelete() throws CoreException {
|
||||||
setWorkspace("regressions");
|
setWorkspace("regressions");
|
||||||
final IProject app = loadProject("helloworldC");
|
final IProject app = loadProject("helloworldC");
|
||||||
|
@ -52,7 +59,7 @@ public class Bug_303953Test extends AbstractBuilderTest {
|
||||||
|
|
||||||
// Delete helloworldC
|
// Delete helloworldC
|
||||||
IFile srcFile = app.getFile("src/helloworldC.c");
|
IFile srcFile = app.getFile("src/helloworldC.c");
|
||||||
assertTrue("1.1", srcFile.exists());
|
assertTrue(srcFile.exists(), "1.1");
|
||||||
srcFile.delete(false, null);
|
srcFile.delete(false, null);
|
||||||
|
|
||||||
// Build again
|
// Build again
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.core.regressions;
|
package org.eclipse.cdt.managedbuilder.core.regressions;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -27,22 +30,25 @@ import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tests that an environment variable, which is part of the build
|
* This tests that an environment variable, which is part of the build
|
||||||
* (in this case referenced by a -I), makes it through to makefile
|
* (in this case referenced by a -I), makes it through to makefile
|
||||||
* correctly when it changes.
|
* correctly when it changes.
|
||||||
*/
|
*/
|
||||||
public class Bug_335476 extends AbstractBuilderTest {
|
@Disabled("This is a test for a known failure - see Bug 335476")
|
||||||
|
public class Bug_335476Test extends AbstractBuilderTest {
|
||||||
|
|
||||||
private final String VAR_NAME = "INC";
|
private final String VAR_NAME = "INC";
|
||||||
IProject app;
|
IProject app;
|
||||||
IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
|
IEnvironmentVariableManager envManager = CCorePlugin.getDefault().getBuildEnvironmentManager();
|
||||||
ICdtVariableManager buildMacroManager = CCorePlugin.getDefault().getCdtVariableManager();
|
ICdtVariableManager buildMacroManager = CCorePlugin.getDefault().getCdtVariableManager();
|
||||||
|
|
||||||
@Override
|
@BeforeEach
|
||||||
protected void setUp() throws Exception {
|
public void setUpLocal() throws Exception {
|
||||||
super.setUp();
|
|
||||||
setWorkspace("regressions");
|
setWorkspace("regressions");
|
||||||
app = loadProject("bug_335476");
|
app = loadProject("bug_335476");
|
||||||
// Ensure Debug is the active configuration
|
// Ensure Debug is the active configuration
|
||||||
|
@ -94,11 +100,9 @@ public class Bug_335476 extends AbstractBuilderTest {
|
||||||
String value2 = buildMacroManager.resolveValue("${" + VAR_NAME + "}", "", ";",
|
String value2 = buildMacroManager.resolveValue("${" + VAR_NAME + "}", "", ";",
|
||||||
CCorePlugin.getDefault().getProjectDescription(app, false).getActiveConfiguration());
|
CCorePlugin.getDefault().getProjectDescription(app, false).getActiveConfiguration());
|
||||||
|
|
||||||
assertTrue(i + " EnvManager " + expected + " exepected, but was: " + value, expected.equals(value));
|
assertEquals(expected, value, i + " EnvManager " + expected + " exepected, but was: " + value);
|
||||||
assertTrue(i + " CdtVarManager " + expected + " exepected, but was: " + value2,
|
assertEquals(expected, value2, i + " CdtVarManager " + expected + " exepected, but was: " + value2);
|
||||||
expected.equals(value2));
|
assertEquals(expected, buildVar, i + " Makefile: " + expected + " exepected, but was: " + buildVar);
|
||||||
assertTrue(i + " Makefile: " + expected + " exepected, but was: " + buildVar,
|
|
||||||
expected.equals(buildVar));
|
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
// Check that we at least matched
|
// Check that we at least matched
|
||||||
|
@ -115,10 +119,12 @@ public class Bug_335476 extends AbstractBuilderTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testChangingEnvironmentBuildSystem_FULL_BUILD() throws Exception {
|
public void testChangingEnvironmentBuildSystem_FULL_BUILD() throws Exception {
|
||||||
runTest(IncrementalProjectBuilder.FULL_BUILD);
|
runTest(IncrementalProjectBuilder.FULL_BUILD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testChangingEnvironmentBuildSystem_INC_BUILD() throws Exception {
|
public void testChangingEnvironmentBuildSystem_INC_BUILD() throws Exception {
|
||||||
runTest(IncrementalProjectBuilder.INCREMENTAL_BUILD);
|
runTest(IncrementalProjectBuilder.INCREMENTAL_BUILD);
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ public class RegressionTestSuite extends TestCase {
|
||||||
TestSuite suite = new TestSuite(RegressionTestSuite.class.getName());
|
TestSuite suite = new TestSuite(RegressionTestSuite.class.getName());
|
||||||
|
|
||||||
// Test that common builder does the correct amount of work.
|
// Test that common builder does the correct amount of work.
|
||||||
suite.addTestSuite(Bug_303953Test.class);
|
// Test converted to JUnit5: suite.addTest(new JUnit4TestAdapter(Bug_303953Test.class));
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.core.tests;
|
package org.eclipse.cdt.managedbuilder.core.tests;
|
||||||
|
|
||||||
|
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 java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.testplugin.AbstractBuilderTest;
|
import org.eclipse.cdt.managedbuilder.testplugin.AbstractBuilderTest;
|
||||||
|
@ -24,34 +28,37 @@ import org.eclipse.core.resources.IWorkspaceDescription;
|
||||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ManagedBuildClean extends AbstractBuilderTest {
|
public class ManagedBuildClean extends AbstractBuilderTest {
|
||||||
private static final String PROJ_PATH = "testCleanProjects";
|
private static final String PROJ_PATH = "testCleanProjects";
|
||||||
private IProject fInternalBuilderProject;
|
private IProject fInternalBuilderProject;
|
||||||
private IProject fExternalBuilderProject;
|
private IProject fExternalBuilderProject;
|
||||||
|
|
||||||
@Override
|
@BeforeEach
|
||||||
protected void setUp() throws Exception {
|
public void setUpLocal() throws Exception {
|
||||||
super.setUp();
|
|
||||||
IWorkspaceDescription wsDescription = ResourcesPlugin.getWorkspace().getDescription();
|
IWorkspaceDescription wsDescription = ResourcesPlugin.getWorkspace().getDescription();
|
||||||
wsDescription.setAutoBuilding(false);
|
wsDescription.setAutoBuilding(false);
|
||||||
ResourcesPlugin.getWorkspace().setDescription(wsDescription);
|
ResourcesPlugin.getWorkspace().setDescription(wsDescription);
|
||||||
assertNotNull("Cannot create testCleanInternal project",
|
assertNotNull(fInternalBuilderProject = ManagedBuildTestHelper.loadProject("testCleanInternal", PROJ_PATH),
|
||||||
fInternalBuilderProject = ManagedBuildTestHelper.loadProject("testCleanInternal", PROJ_PATH));
|
"Cannot create testCleanInternal project");
|
||||||
assertNotNull("Cannot create testCleanExternal project",
|
assertNotNull(fExternalBuilderProject = ManagedBuildTestHelper.loadProject("testCleanExternal", PROJ_PATH),
|
||||||
fExternalBuilderProject = ManagedBuildTestHelper.loadProject("testCleanExternal", PROJ_PATH));
|
"Cannot create testCleanExternal project");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@AfterEach
|
||||||
protected void tearDown() throws Exception {
|
public void tearDownLocal() throws Exception {
|
||||||
super.tearDown();
|
|
||||||
ManagedBuildTestHelper.removeProject(fInternalBuilderProject.getName());
|
ManagedBuildTestHelper.removeProject(fInternalBuilderProject.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCleanInternal() throws Exception {
|
public void testCleanInternal() throws Exception {
|
||||||
helperTestClean(fInternalBuilderProject, false);
|
helperTestClean(fInternalBuilderProject, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCleanExternal() throws Exception {
|
public void testCleanExternal() throws Exception {
|
||||||
helperTestClean(fExternalBuilderProject, true);
|
helperTestClean(fExternalBuilderProject, true);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +70,7 @@ public class ManagedBuildClean extends AbstractBuilderTest {
|
||||||
Collection<IResource> resources = getProjectBuildExeResources(project.getName(), "Debug",
|
Collection<IResource> resources = getProjectBuildExeResources(project.getName(), "Debug",
|
||||||
"src/" + project.getName(), externalBuilder);
|
"src/" + project.getName(), externalBuilder);
|
||||||
for (IResource resource : resources) {
|
for (IResource resource : resources) {
|
||||||
assertTrue("Resource not found: " + resource, resource.exists());
|
assertTrue(resource.exists(), "Resource not found: " + resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do a clean and make sure files are gone
|
// do a clean and make sure files are gone
|
||||||
|
@ -77,7 +84,7 @@ public class ManagedBuildClean extends AbstractBuilderTest {
|
||||||
// makefiles are not removed when cleaning
|
// makefiles are not removed when cleaning
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
assertFalse("Resource not deleted: " + resource, resource.exists());
|
assertFalse(resource.exists(), "Resource not deleted: " + resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.core.tests;
|
package org.eclipse.cdt.managedbuilder.core.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.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -40,9 +44,9 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.OperationCanceledException;
|
import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import junit.framework.Test;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import junit.framework.TestSuite;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ManagedBuildDependencyLibsTests extends AbstractBuilderTest {
|
public class ManagedBuildDependencyLibsTests extends AbstractBuilderTest {
|
||||||
private static final String PROJ_PATH = "depLibsProjects";
|
private static final String PROJ_PATH = "depLibsProjects";
|
||||||
|
@ -52,19 +56,6 @@ public class ManagedBuildDependencyLibsTests extends AbstractBuilderTest {
|
||||||
|
|
||||||
private IToolChain[] allToolChains;
|
private IToolChain[] allToolChains;
|
||||||
|
|
||||||
public ManagedBuildDependencyLibsTests(String name) {
|
|
||||||
super(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Test suite() {
|
|
||||||
TestSuite suite = new TestSuite(ManagedBuildDependencyLibsTests.class.getName());
|
|
||||||
|
|
||||||
suite.addTest(new ManagedBuildDependencyLibsTests("testDepLibs"));
|
|
||||||
suite.addTest(new ManagedBuildDependencyLibsTests("testDepUObjs"));
|
|
||||||
suite.addTest(new ManagedBuildDependencyLibsTests("testGetArtifactTimeStampEscapeURI_bug377295"));
|
|
||||||
return suite;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildProject(IProject curProject) {
|
private void buildProject(IProject curProject) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -84,27 +75,30 @@ public class ManagedBuildDependencyLibsTests extends AbstractBuilderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
public void setUp() {
|
||||||
super.setUp();
|
// Don't run super class setUp
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void setUpLocal() throws Exception {
|
||||||
allToolChains = ManagedBuildManager.getRealToolChains();
|
allToolChains = ManagedBuildManager.getRealToolChains();
|
||||||
IWorkspaceDescription wsDescription = ResourcesPlugin.getWorkspace().getDescription();
|
IWorkspaceDescription wsDescription = ResourcesPlugin.getWorkspace().getDescription();
|
||||||
wsDescription.setAutoBuilding(false);
|
wsDescription.setAutoBuilding(false);
|
||||||
ResourcesPlugin.getWorkspace().setDescription(wsDescription);
|
ResourcesPlugin.getWorkspace().setDescription(wsDescription);
|
||||||
assertNotNull("Cannot create tapp project", fTapp = ManagedBuildTestHelper.loadProject("tapp", PROJ_PATH));
|
assertNotNull(fTapp = ManagedBuildTestHelper.loadProject("tapp", PROJ_PATH), "Cannot create tapp project");
|
||||||
assertNotNull("Cannot create tlib project", fTlib = ManagedBuildTestHelper.loadProject("tlib", PROJ_PATH));
|
assertNotNull(fTlib = ManagedBuildTestHelper.loadProject("tlib", PROJ_PATH), "Cannot create tlib project");
|
||||||
assertNotNull("Cannot create tobjs project", fTobjs = ManagedBuildTestHelper.loadProject("tobjs", PROJ_PATH));
|
assertNotNull(fTobjs = ManagedBuildTestHelper.loadProject("tobjs", PROJ_PATH), "Cannot create tobjs project");
|
||||||
IProjectDescription projDescription = fTapp.getDescription();
|
IProjectDescription projDescription = fTapp.getDescription();
|
||||||
projDescription.setReferencedProjects(new IProject[] { fTlib, fTobjs });
|
projDescription.setReferencedProjects(new IProject[] { fTlib, fTobjs });
|
||||||
fTapp.setDescription(projDescription, new NullProgressMonitor());
|
fTapp.setDescription(projDescription, new NullProgressMonitor());
|
||||||
IToolChain toolChain = setToolChain(fTapp, null);
|
IToolChain toolChain = setToolChain(fTapp, null);
|
||||||
assertNotNull("No compatible tool chain.", toolChain);
|
assertNotNull(toolChain, "No compatible tool chain.");
|
||||||
setToolChain(fTlib, toolChain);
|
setToolChain(fTlib, toolChain);
|
||||||
setToolChain(fTobjs, toolChain);
|
setToolChain(fTobjs, toolChain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@AfterEach
|
||||||
protected void tearDown() throws Exception {
|
public void tearDownLocal() throws Exception {
|
||||||
super.tearDown();
|
|
||||||
ManagedBuildTestHelper.removeProject(fTapp.getName());
|
ManagedBuildTestHelper.removeProject(fTapp.getName());
|
||||||
ManagedBuildTestHelper.removeProject(fTlib.getName());
|
ManagedBuildTestHelper.removeProject(fTlib.getName());
|
||||||
ManagedBuildTestHelper.removeProject(fTobjs.getName());
|
ManagedBuildTestHelper.removeProject(fTobjs.getName());
|
||||||
|
@ -215,6 +209,7 @@ public class ManagedBuildDependencyLibsTests extends AbstractBuilderTest {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDepLibs() {
|
public void testDepLibs() {
|
||||||
buildProject(fTapp);
|
buildProject(fTapp);
|
||||||
long timeStamp = getArtifactTimeStamp(fTapp);
|
long timeStamp = getArtifactTimeStamp(fTapp);
|
||||||
|
@ -238,6 +233,7 @@ public class ManagedBuildDependencyLibsTests extends AbstractBuilderTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDepUObjs() {
|
public void testDepUObjs() {
|
||||||
buildProject(fTapp);
|
buildProject(fTapp);
|
||||||
long timeStamp = getArtifactTimeStamp(fTapp);
|
long timeStamp = getArtifactTimeStamp(fTapp);
|
||||||
|
@ -264,6 +260,7 @@ public class ManagedBuildDependencyLibsTests extends AbstractBuilderTest {
|
||||||
|
|
||||||
// Tests that the URI used to get the time stamp of the artifact is escaped correctly
|
// Tests that the URI used to get the time stamp of the artifact is escaped correctly
|
||||||
// See AdditionalInput.getArtifactTimeStamp(IToolChain toolChain)
|
// See AdditionalInput.getArtifactTimeStamp(IToolChain toolChain)
|
||||||
|
@Test
|
||||||
public void testGetArtifactTimeStampEscapeURI_bug377295() throws CoreException {
|
public void testGetArtifactTimeStampEscapeURI_bug377295() throws CoreException {
|
||||||
setWorkspace("regressions");
|
setWorkspace("regressions");
|
||||||
final IProject project = loadProject("helloworldC");
|
final IProject project = loadProject("helloworldC");
|
||||||
|
|
|
@ -16,6 +16,12 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.cdescriptor.tests;
|
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.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
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.ICProjectDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICStorageElement;
|
import org.eclipse.cdt.core.settings.model.ICStorageElement;
|
||||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
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.cdt.internal.core.pdom.PDOMManager;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
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.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import junit.framework.Test;
|
@Tag(BaseTestCase5.FLAKY_TEST_TAG)
|
||||||
import junit.framework.TestSuite;
|
public class CDescriptorTests extends BaseTestCase5 {
|
||||||
|
|
||||||
public class CDescriptorTests extends BaseTestCase {
|
|
||||||
static String projectId = CTestPlugin.PLUGIN_ID + ".TestProject";
|
static String projectId = CTestPlugin.PLUGIN_ID + ".TestProject";
|
||||||
static IProject fProject;
|
static IProject fProject;
|
||||||
static CDescriptorListener listener = new CDescriptorListener();
|
static CDescriptorListener listener = new CDescriptorListener();
|
||||||
static volatile CDescriptorEvent fLastEvent;
|
static volatile CDescriptorEvent fLastEvent;
|
||||||
|
|
||||||
/**
|
@BeforeEach
|
||||||
* Constructor for CDescriptorTest.
|
protected void setUpLocal() throws Exception {
|
||||||
*
|
|
||||||
* @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 {
|
|
||||||
CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
CTestPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
|
@ -97,8 +90,8 @@ public class CDescriptorTests extends BaseTestCase {
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@AfterEach
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDownLocal() throws Exception {
|
||||||
fProject.delete(true, true, null);
|
fProject.delete(true, true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,29 +113,32 @@ public class CDescriptorTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDescriptorCreation() throws Exception {
|
public void testDescriptorCreation() throws Exception {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||||
|
|
||||||
Assert.assertNotNull(fLastEvent);
|
assertNotNull(fLastEvent);
|
||||||
Assert.assertEquals(fLastEvent.getDescriptor(), desc);
|
assertEquals(fLastEvent.getDescriptor(), desc);
|
||||||
Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_ADDED);
|
assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_ADDED);
|
||||||
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
assertEquals(fLastEvent.getFlags(), 0);
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
|
|
||||||
Assert.assertEquals(fProject, desc.getProject());
|
assertEquals(fProject, desc.getProject());
|
||||||
Assert.assertEquals("*", desc.getPlatform());
|
assertEquals("*", desc.getPlatform());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDescriptorOwner() throws Exception {
|
public void testDescriptorOwner() throws Exception {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||||
ICOwnerInfo owner = desc.getProjectOwner();
|
ICOwnerInfo owner = desc.getProjectOwner();
|
||||||
Assert.assertEquals(projectId, owner.getID());
|
assertEquals(projectId, owner.getID());
|
||||||
Assert.assertEquals("*", owner.getPlatform());
|
assertEquals("*", owner.getPlatform());
|
||||||
Assert.assertEquals("C/C++ Test Project", owner.getName());
|
assertEquals("C/C++ Test Project", owner.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disabled this test because it fails every now and then and it tests deprecated API
|
// 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
|
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=340123
|
||||||
|
// @Test
|
||||||
public void _testConcurrentDescriptorCreation() throws Exception {
|
public void _testConcurrentDescriptorCreation() throws Exception {
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
fProject.close(null);
|
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=185930
|
||||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=193503
|
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=193503
|
||||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=196118
|
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=196118
|
||||||
|
@Test
|
||||||
public void testConcurrentDescriptorModification() throws Exception {
|
public void testConcurrentDescriptorModification() throws Exception {
|
||||||
int lastLength = 0;
|
int lastLength = 0;
|
||||||
for (int i = 0; i < 100; ++i) {
|
for (int i = 0; i < 100; ++i) {
|
||||||
|
@ -230,12 +227,12 @@ public class CDescriptorTests extends BaseTestCase {
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertNull("Exception occurred: " + exception[j], exception[j]);
|
assertNull(exception[j], "Exception occurred: " + exception[j]);
|
||||||
}
|
}
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||||
int lengthAfter = desc.getProjectStorageElement("testElement").getChildren().length;
|
int lengthAfter = desc.getProjectStorageElement("testElement").getChildren().length;
|
||||||
lastLength += threads.length; // Update last lengths to what we expect
|
lastLength += threads.length; // Update last lengths to what we expect
|
||||||
assertEquals("Iteration count: " + i, lastLength, lengthAfter);
|
assertEquals(lastLength, lengthAfter, "Iteration count: " + i);
|
||||||
|
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
}
|
}
|
||||||
|
@ -245,6 +242,7 @@ public class CDescriptorTests extends BaseTestCase {
|
||||||
* This test should pass as two threads, operating on the different storage elements
|
* This test should pass as two threads, operating on the different storage elements
|
||||||
* (outside of an operation) should be safe.
|
* (outside of an operation) should be safe.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testConcurrentDifferentStorageElementModification() throws Exception {
|
public void testConcurrentDifferentStorageElementModification() throws Exception {
|
||||||
for (int i = 0; i < 100; ++i) {
|
for (int i = 0; i < 100; ++i) {
|
||||||
Thread t = new Thread() {
|
Thread t = new Thread() {
|
||||||
|
@ -273,15 +271,16 @@ public class CDescriptorTests extends BaseTestCase {
|
||||||
|
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
}
|
}
|
||||||
Assert.assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
|
assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
|
||||||
.getProjectStorageElement("testElement4").getChildren().length);
|
.getProjectStorageElement("testElement4").getChildren().length);
|
||||||
Assert.assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
|
assertEquals(100, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
|
||||||
.getProjectStorageElement("testElement5").getChildren().length);
|
.getProjectStorageElement("testElement5").getChildren().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tests that (non-structural) changes to the storage element tree work as expected.
|
* Tests that (non-structural) changes to the storage element tree work as expected.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testConcurrentSameStorageElementModification() throws Exception {
|
public void testConcurrentSameStorageElementModification() throws Exception {
|
||||||
for (int i = 0; i < 100; ++i) {
|
for (int i = 0; i < 100; ++i) {
|
||||||
Thread t = new Thread() {
|
Thread t = new Thread() {
|
||||||
|
@ -310,17 +309,18 @@ public class CDescriptorTests extends BaseTestCase {
|
||||||
|
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
}
|
}
|
||||||
Assert.assertEquals(200, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
|
assertEquals(200, CCorePlugin.getDefault().getCProjectDescription(fProject, false)
|
||||||
.getProjectStorageElement("testElement6").getChildren().length);
|
.getProjectStorageElement("testElement6").getChildren().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tests deadlock when accessing c project description concurrently from two threads
|
* Tests deadlock when accessing c project description concurrently from two threads
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testDeadlockDuringProjectCreation() throws Exception {
|
public void testDeadlockDuringProjectCreation() throws Exception {
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
tearDown();
|
tearDownLocal();
|
||||||
setUp();
|
setUpLocal();
|
||||||
Thread t = new Thread() {
|
Thread t = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -348,33 +348,37 @@ public class CDescriptorTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDescriptorConversion() {
|
public void testDescriptorConversion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testExtensionCreation() throws Exception {
|
public void testExtensionCreation() throws Exception {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||||
ICExtensionReference extRef = desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
|
ICExtensionReference extRef = desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
|
||||||
|
|
||||||
Assert.assertNotNull(fLastEvent);
|
assertNotNull(fLastEvent);
|
||||||
Assert.assertEquals(fLastEvent.getDescriptor(), desc);
|
assertEquals(fLastEvent.getDescriptor(), desc);
|
||||||
Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
||||||
Assert.assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED);
|
assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED);
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
|
|
||||||
Assert.assertEquals("org.eclipse.cdt.testextension", extRef.getExtension());
|
assertEquals("org.eclipse.cdt.testextension", extRef.getExtension());
|
||||||
Assert.assertEquals("org.eclipse.cdt.testextensionID", extRef.getID());
|
assertEquals("org.eclipse.cdt.testextensionID", extRef.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testExtensionGet() throws Exception {
|
public void testExtensionGet() throws Exception {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||||
desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
|
desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
|
||||||
|
|
||||||
ICExtensionReference extRef[] = desc.get("org.eclipse.cdt.testextension");
|
ICExtensionReference extRef[] = desc.get("org.eclipse.cdt.testextension");
|
||||||
|
|
||||||
Assert.assertEquals("org.eclipse.cdt.testextension", extRef[0].getExtension());
|
assertEquals("org.eclipse.cdt.testextension", extRef[0].getExtension());
|
||||||
Assert.assertEquals("org.eclipse.cdt.testextensionID", extRef[0].getID());
|
assertEquals("org.eclipse.cdt.testextensionID", extRef[0].getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testExtensionData() throws Exception {
|
public void testExtensionData() throws Exception {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||||
desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
|
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");
|
ICExtensionReference extRef[] = desc.get("org.eclipse.cdt.testextension");
|
||||||
extRef[0].setExtensionData("testKey", "testValue");
|
extRef[0].setExtensionData("testKey", "testValue");
|
||||||
|
|
||||||
Assert.assertNotNull(fLastEvent);
|
assertNotNull(fLastEvent);
|
||||||
Assert.assertEquals(fLastEvent.getDescriptor(), desc);
|
assertEquals(fLastEvent.getDescriptor(), desc);
|
||||||
Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
||||||
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
assertEquals(fLastEvent.getFlags(), 0);
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
|
|
||||||
Assert.assertEquals("testValue", extRef[0].getExtensionData("testKey"));
|
assertEquals("testValue", extRef[0].getExtensionData("testKey"));
|
||||||
extRef[0].setExtensionData("testKey", null);
|
extRef[0].setExtensionData("testKey", null);
|
||||||
Assert.assertEquals(null, extRef[0].getExtensionData("testKey"));
|
assertEquals(null, extRef[0].getExtensionData("testKey"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testExtensionRemove() throws Exception {
|
public void testExtensionRemove() throws Exception {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||||
desc.create("org.eclipse.cdt.testextension", "org.eclipse.cdt.testextensionID");
|
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");
|
ICExtensionReference extRef[] = desc.get("org.eclipse.cdt.testextension");
|
||||||
desc.remove(extRef[0]);
|
desc.remove(extRef[0]);
|
||||||
|
|
||||||
Assert.assertNotNull(fLastEvent);
|
assertNotNull(fLastEvent);
|
||||||
Assert.assertEquals(fLastEvent.getDescriptor(), desc);
|
assertEquals(fLastEvent.getDescriptor(), desc);
|
||||||
Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
||||||
Assert.assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED);
|
assertEquals(fLastEvent.getFlags(), CDescriptorEvent.EXTENSION_CHANGED);
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testProjectDataCreate() throws Exception {
|
public void testProjectDataCreate() throws Exception {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||||
ICStorageElement data = desc.getProjectStorageElement("testElement");
|
ICStorageElement data = desc.getProjectStorageElement("testElement");
|
||||||
data.createChild("test");
|
data.createChild("test");
|
||||||
desc.saveProjectData();
|
desc.saveProjectData();
|
||||||
|
|
||||||
Assert.assertNotNull(fLastEvent);
|
assertNotNull(fLastEvent);
|
||||||
Assert.assertEquals(fLastEvent.getDescriptor(), desc);
|
assertEquals(fLastEvent.getDescriptor(), desc);
|
||||||
Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
||||||
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
assertEquals(fLastEvent.getFlags(), 0);
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testProjectDataDelete() throws Exception {
|
public void testProjectDataDelete() throws Exception {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||||
ICStorageElement data = desc.getProjectStorageElement("testElement");
|
ICStorageElement data = desc.getProjectStorageElement("testElement");
|
||||||
data.createChild("test");
|
data.createChild("test");
|
||||||
|
|
||||||
ICStorageElement[] list = data.getChildrenByName("test");
|
ICStorageElement[] list = data.getChildrenByName("test");
|
||||||
Assert.assertEquals(1, list.length);
|
assertEquals(1, list.length);
|
||||||
data.removeChild(list[0]);
|
data.removeChild(list[0]);
|
||||||
desc.saveProjectData();
|
desc.saveProjectData();
|
||||||
|
|
||||||
Assert.assertNotNull(fLastEvent);
|
assertNotNull(fLastEvent);
|
||||||
Assert.assertEquals(fLastEvent.getDescriptor(), desc);
|
assertEquals(fLastEvent.getDescriptor(), desc);
|
||||||
Assert.assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
assertEquals(fLastEvent.getType(), CDescriptorEvent.CDTPROJECT_CHANGED);
|
||||||
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
assertEquals(fLastEvent.getFlags(), 0);
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCProjectDescriptionDescriptorInteraction() throws Exception {
|
public void testCProjectDescriptionDescriptorInteraction() throws Exception {
|
||||||
for (int i = 1; i < 100; i++) {
|
for (int i = 1; i < 100; i++) {
|
||||||
// Create a descriptor with some test data
|
// Create a descriptor with some test data
|
||||||
|
@ -469,6 +477,7 @@ public class CDescriptorTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAccumulatingBlankLinesInProjectData() throws Exception {
|
public void testAccumulatingBlankLinesInProjectData() throws Exception {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||||
ICStorageElement data = desc.getProjectStorageElement("testElement");
|
ICStorageElement data = desc.getProjectStorageElement("testElement");
|
||||||
|
@ -491,8 +500,8 @@ public class CDescriptorTests extends BaseTestCase {
|
||||||
|
|
||||||
String dotCProject2 = readDotCProjectFile(fProject);
|
String dotCProject2 = readDotCProjectFile(fProject);
|
||||||
long mtime2 = fProject.getFile(".cproject").getLocalTimeStamp();
|
long mtime2 = fProject.getFile(".cproject").getLocalTimeStamp();
|
||||||
assertEquals("Difference in .cproject file", dotCProject1, dotCProject2);
|
assertEquals(dotCProject1, dotCProject2, "Difference in .cproject file");
|
||||||
assertTrue(".cproject file has been written", mtime1 == mtime2);
|
assertTrue(mtime1 == mtime2, ".cproject file has been written");
|
||||||
|
|
||||||
// do it a second time - just to be sure
|
// do it a second time - just to be sure
|
||||||
fProject.close(null);
|
fProject.close(null);
|
||||||
|
@ -508,8 +517,8 @@ public class CDescriptorTests extends BaseTestCase {
|
||||||
|
|
||||||
String dotCProject3 = readDotCProjectFile(fProject);
|
String dotCProject3 = readDotCProjectFile(fProject);
|
||||||
long mtime3 = fProject.getFile(".cproject").getLocalTimeStamp();
|
long mtime3 = fProject.getFile(".cproject").getLocalTimeStamp();
|
||||||
assertEquals("Difference in .cproject file", dotCProject2, dotCProject3);
|
assertEquals(dotCProject2, dotCProject3, "Difference in .cproject file");
|
||||||
assertTrue(".cproject file has been written", mtime2 == mtime3);
|
assertTrue(mtime2 == mtime3, ".cproject file has been written");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class AllLanguageSettingsProvidersCoreTestSuite {
|
||||||
suite.addTest(LanguageSettingsExtensionsTests.suite());
|
suite.addTest(LanguageSettingsExtensionsTests.suite());
|
||||||
suite.addTest(LanguageSettingsManagerTests.suite());
|
suite.addTest(LanguageSettingsManagerTests.suite());
|
||||||
suite.addTest(LanguageSettingsSerializableProviderTests.suite());
|
suite.addTest(LanguageSettingsSerializableProviderTests.suite());
|
||||||
suite.addTest(LanguageSettingsPersistenceProjectTests.suite());
|
// Test converted to JUnit5: suite.addTest(LanguageSettingsPersistenceProjectTests.suite());
|
||||||
suite.addTest(LanguageSettingsListenersTests.suite());
|
suite.addTest(LanguageSettingsListenersTests.suite());
|
||||||
suite.addTest(LanguageSettingsScannerInfoProviderTests.suite());
|
suite.addTest(LanguageSettingsScannerInfoProviderTests.suite());
|
||||||
suite.addTest(LanguageSettingsProviderReferencedProjectsTests.suite());
|
suite.addTest(LanguageSettingsProviderReferencedProjectsTests.suite());
|
||||||
|
|
|
@ -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
|
* This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License 2.0
|
* 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;
|
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.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
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.settings.model.WriteAccessException;
|
||||||
import org.eclipse.cdt.core.testplugin.CModelMock;
|
import org.eclipse.cdt.core.testplugin.CModelMock;
|
||||||
import org.eclipse.cdt.core.testplugin.ResourceHelper;
|
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.XmlUtil;
|
||||||
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
|
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
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.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IPath;
|
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.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cases testing LanguageSettingsProvider functionality related to persistence.
|
* 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
|
// 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_ID = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_ID;
|
||||||
private static final String EXTENSION_BASE_PROVIDER_NAME = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_NAME;
|
private static final String EXTENSION_BASE_PROVIDER_NAME = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_NAME;
|
||||||
|
@ -130,39 +138,9 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@AfterEach
|
||||||
* Constructor.
|
protected void tearDownLocal() throws Exception {
|
||||||
* @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 {
|
|
||||||
LanguageSettingsManager.setWorkspaceProviders(null);
|
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.
|
* Persist and reload when no customized providers are defined in the workspace.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testWorkspacePersistence_NoProviders() throws Exception {
|
public void testWorkspacePersistence_NoProviders() throws Exception {
|
||||||
// serialize language settings of user defined providers (on workspace level)
|
// serialize language settings of user defined providers (on workspace level)
|
||||||
LanguageSettingsProvidersSerializer.serializeLanguageSettingsWorkspace();
|
LanguageSettingsProvidersSerializer.serializeLanguageSettingsWorkspace();
|
||||||
|
@ -206,6 +185,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Make sure providers in configuration cannot be modified accidentally outside of API.
|
* Make sure providers in configuration cannot be modified accidentally outside of API.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectDescription_PreventBackDoorAccess() throws Exception {
|
public void testProjectDescription_PreventBackDoorAccess() throws Exception {
|
||||||
// create a project
|
// create a project
|
||||||
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
|
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 assigning providers to read-only vs. writable configuration descriptions.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectDescription_ReadWriteDescription() throws Exception {
|
public void testProjectDescription_ReadWriteDescription() throws Exception {
|
||||||
// create a project
|
// create a project
|
||||||
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
|
IProject project = ResourceHelper.createCDTProjectWithConfig(getName());
|
||||||
|
@ -367,6 +348,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Persist and reload a customized provider defined in the workspace.
|
* Persist and reload a customized provider defined in the workspace.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testWorkspacePersistence_ModifiedExtensionProvider() throws Exception {
|
public void testWorkspacePersistence_ModifiedExtensionProvider() throws Exception {
|
||||||
List<ICLanguageSettingEntry> entries = new ArrayList<>();
|
List<ICLanguageSettingEntry> entries = new ArrayList<>();
|
||||||
entries.add(new CIncludePathEntry("path0", 0));
|
entries.add(new CIncludePathEntry("path0", 0));
|
||||||
|
@ -416,6 +398,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Check persistence of unmodified extension provider in the workspace.
|
* Check persistence of unmodified extension provider in the workspace.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testWorkspacePersistence_UnmodifiedExtensionProvider() throws Exception {
|
public void testWorkspacePersistence_UnmodifiedExtensionProvider() throws Exception {
|
||||||
List<ICLanguageSettingEntry> extensionEntries = new ArrayList<>();
|
List<ICLanguageSettingEntry> extensionEntries = new ArrayList<>();
|
||||||
extensionEntries.add(EXTENSION_SERIALIZABLE_PROVIDER_ENTRY);
|
extensionEntries.add(EXTENSION_SERIALIZABLE_PROVIDER_ENTRY);
|
||||||
|
@ -463,6 +446,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test persistence of global providers in the workspace.
|
* Test persistence of global providers in the workspace.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testWorkspacePersistence_GlobalProvider() throws Exception {
|
public void testWorkspacePersistence_GlobalProvider() throws Exception {
|
||||||
{
|
{
|
||||||
// get the raw extension provider
|
// 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 persistence of global providers with ID matching an extension provider in the workspace.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testWorkspacePersistence_ShadowedExtensionProvider() throws Exception {
|
public void testWorkspacePersistence_ShadowedExtensionProvider() throws Exception {
|
||||||
{
|
{
|
||||||
// get the raw extension provider
|
// get the raw extension provider
|
||||||
|
@ -569,6 +554,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test serialization of providers to project storage.
|
* Test serialization of providers to project storage.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_SerializableProviderDOM() throws Exception {
|
public void testProjectPersistence_SerializableProviderDOM() throws Exception {
|
||||||
Element rootElement = null;
|
Element rootElement = null;
|
||||||
|
|
||||||
|
@ -631,6 +617,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test User language settings provider defined as extension in cdt.ui.
|
* Test User language settings provider defined as extension in cdt.ui.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_UserProviderDOM() throws Exception {
|
public void testProjectPersistence_UserProviderDOM() throws Exception {
|
||||||
Element rootElement = null;
|
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 serialization of providers to project storage where the project has multiple configurations.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_TwoConfigurationsDOM() throws Exception {
|
public void testProjectPersistence_TwoConfigurationsDOM() throws Exception {
|
||||||
Element rootElement = null;
|
Element rootElement = null;
|
||||||
|
|
||||||
|
@ -837,6 +825,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test serialization of providers subclassing {@link LanguageSettingsSerializableProvider}.
|
* Test serialization of providers subclassing {@link LanguageSettingsSerializableProvider}.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_SubclassedSerializableProviderDOM() throws Exception {
|
public void testProjectPersistence_SubclassedSerializableProviderDOM() throws Exception {
|
||||||
Element rootElement = null;
|
Element rootElement = null;
|
||||||
|
|
||||||
|
@ -898,6 +887,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Serialization of providers exactly equal extension providers.
|
* Serialization of providers exactly equal extension providers.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_ReferenceExtensionProviderDOM() throws Exception {
|
public void testProjectPersistence_ReferenceExtensionProviderDOM() throws Exception {
|
||||||
Element rootElement = null;
|
Element rootElement = null;
|
||||||
|
|
||||||
|
@ -953,6 +943,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test serialization of providers overriding/shadowing extension providers.
|
* Test serialization of providers overriding/shadowing extension providers.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_OverrideExtensionProviderDOM() throws Exception {
|
public void testProjectPersistence_OverrideExtensionProviderDOM() throws Exception {
|
||||||
Element rootElement = null;
|
Element rootElement = null;
|
||||||
|
|
||||||
|
@ -1013,6 +1004,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test serialization flavors in one storage.
|
* Test serialization flavors in one storage.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_MixedProvidersDOM() throws Exception {
|
public void testProjectPersistence_MixedProvidersDOM() throws Exception {
|
||||||
Element rootElement = null;
|
Element rootElement = null;
|
||||||
|
|
||||||
|
@ -1107,6 +1099,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test serialization of real project.
|
* Test serialization of real project.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_RealProject() throws Exception {
|
public void testProjectPersistence_RealProject() throws Exception {
|
||||||
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
||||||
IFile xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
IFile xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
||||||
|
@ -1224,17 +1217,17 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
String xmlStorageFileLocation = xmlStorageFilePrj.getLocation().toOSString();
|
String xmlStorageFileLocation = xmlStorageFilePrj.getLocation().toOSString();
|
||||||
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
|
java.io.File xmlFile = new java.io.File(xmlStorageFileLocation);
|
||||||
xmlFile.delete();
|
xmlFile.delete();
|
||||||
assertFalse("File " + xmlFile + " still exist", xmlFile.exists());
|
assertNotExists(xmlFile);
|
||||||
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
|
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
|
||||||
xmlFileOut.renameTo(xmlFile);
|
xmlFileOut.renameTo(xmlFile);
|
||||||
assertTrue("File " + xmlFile + " does not exist", xmlFile.exists());
|
assertExists(xmlFile);
|
||||||
assertFalse("File " + xmlFileOut + " still exist", xmlFileOut.exists());
|
assertNotExists(xmlFileOut);
|
||||||
|
|
||||||
// Wait out in case indexer thread hijacks refreshLocal(), see bug 415970
|
// Wait out in case indexer thread hijacks refreshLocal(), see bug 415970
|
||||||
waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project));
|
waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project));
|
||||||
// Refresh storage in workspace
|
// Refresh storage in workspace
|
||||||
xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null);
|
xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null);
|
||||||
assertTrue("File " + xmlStorageFilePrj + " does not exist", xmlStorageFilePrj.exists());
|
assertExists(xmlStorageFilePrj);
|
||||||
|
|
||||||
// and close
|
// and close
|
||||||
project.close(null);
|
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 case when the storage is split between project and workspace area.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_SplitStorageDOM() throws Exception {
|
public void testProjectPersistence_SplitStorageDOM() throws Exception {
|
||||||
Element prjStorageElement = null;
|
Element prjStorageElement = null;
|
||||||
Element wspStorageElement = null;
|
Element wspStorageElement = null;
|
||||||
|
@ -1343,6 +1337,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test split storage in a real project.
|
* Test split storage in a real project.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_RealProjectSplitStorage() throws Exception {
|
public void testProjectPersistence_RealProjectSplitStorage() throws Exception {
|
||||||
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
||||||
IFile xmlStorageFilePrj;
|
IFile xmlStorageFilePrj;
|
||||||
|
@ -1472,17 +1467,17 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
String xmlStorageFilePrjLocation = xmlStorageFilePrj.getLocation().toOSString();
|
String xmlStorageFilePrjLocation = xmlStorageFilePrj.getLocation().toOSString();
|
||||||
java.io.File xmlFile = new java.io.File(xmlStorageFilePrjLocation);
|
java.io.File xmlFile = new java.io.File(xmlStorageFilePrjLocation);
|
||||||
xmlFile.delete();
|
xmlFile.delete();
|
||||||
assertFalse("File " + xmlFile + " still exist", xmlFile.exists());
|
assertNotExists(xmlFile);
|
||||||
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
|
java.io.File xmlFileOut = new java.io.File(xmlPrjOutOfTheWay);
|
||||||
xmlFileOut.renameTo(xmlFile);
|
xmlFileOut.renameTo(xmlFile);
|
||||||
assertTrue("File " + xmlFile + " does not exist", xmlFile.exists());
|
assertExists(xmlFile);
|
||||||
assertFalse("File " + xmlFileOut + " still exist", xmlFileOut.exists());
|
assertNotExists(xmlFileOut);
|
||||||
|
|
||||||
// Wait out in case indexer thread hijacks refreshLocal(), see bug 415970
|
// Wait out in case indexer thread hijacks refreshLocal(), see bug 415970
|
||||||
waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project));
|
waitForIndexer(CCorePlugin.getDefault().getCoreModel().create(project));
|
||||||
// Refresh storage in workspace
|
// Refresh storage in workspace
|
||||||
xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null);
|
xmlStorageFilePrj.refreshLocal(IResource.DEPTH_ZERO, null);
|
||||||
assertTrue("File " + xmlStorageFilePrj + " does not exist", xmlStorageFilePrj.exists());
|
assertExists(xmlStorageFilePrj);
|
||||||
|
|
||||||
// and close
|
// and close
|
||||||
project.close(null);
|
project.close(null);
|
||||||
|
@ -1492,11 +1487,11 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
// Move workspace storage back
|
// Move workspace storage back
|
||||||
java.io.File xmlWspFile = new java.io.File(xmlStorageFileWspLocation);
|
java.io.File xmlWspFile = new java.io.File(xmlStorageFileWspLocation);
|
||||||
xmlWspFile.delete();
|
xmlWspFile.delete();
|
||||||
assertFalse("File " + xmlWspFile + " still exist", xmlWspFile.exists());
|
assertNotExists(xmlWspFile);
|
||||||
java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay);
|
java.io.File xmlWspFileOut = new java.io.File(xmlWspOutOfTheWay);
|
||||||
xmlWspFileOut.renameTo(xmlWspFile);
|
xmlWspFileOut.renameTo(xmlWspFile);
|
||||||
assertTrue("File " + xmlWspFile + " does not exist", xmlWspFile.exists());
|
assertExists(xmlWspFile);
|
||||||
assertFalse("File " + xmlWspFileOut + " still exist", xmlWspFileOut.exists());
|
assertNotExists(xmlWspFileOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1525,6 +1520,7 @@ public class LanguageSettingsPersistenceProjectTests extends BaseTestCase {
|
||||||
/**
|
/**
|
||||||
* Test serialization of providers referring to global shared instance.
|
* Test serialization of providers referring to global shared instance.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_ProviderExtensionReferenceDOM() throws Exception {
|
public void testProjectPersistence_ProviderExtensionReferenceDOM() throws Exception {
|
||||||
Document doc = XmlUtil.newDocument();
|
Document doc = XmlUtil.newDocument();
|
||||||
Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST);
|
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.
|
* Walk the scenario when a provider is cloned to a configuration from extension.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_ProviderExtensionCopyDOM() throws Exception {
|
public void testProjectPersistence_ProviderExtensionCopyDOM() throws Exception {
|
||||||
Document doc = XmlUtil.newDocument();
|
Document doc = XmlUtil.newDocument();
|
||||||
Element storageElement = XmlUtil.appendElement(doc, ELEM_TEST);
|
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 that default settings do not cause the files to appear in the project or file-system.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testProjectPersistence_Defaults() throws Exception {
|
public void testProjectPersistence_Defaults() throws Exception {
|
||||||
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName());
|
||||||
IFile xmlStorageFilePrj = project.getFile(LANGUAGE_SETTINGS_PROJECT_XML);
|
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 serialization of global providers exactly equal extension in workspace area.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
|
@Tag(FLAKY_TEST_TAG)
|
||||||
public void testWorkspacePersistence_ProviderExtensionCopy() throws Exception {
|
public void testWorkspacePersistence_ProviderExtensionCopy() throws Exception {
|
||||||
List<ICLanguageSettingEntry> entries = new ArrayList<>();
|
List<ICLanguageSettingEntry> entries = new ArrayList<>();
|
||||||
List<ILanguageSettingsProvider> providers = 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 that default settings do not cause the file to appear on the file-system.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testWorkspacePersistence_Defaults() throws Exception {
|
public void testWorkspacePersistence_Defaults() throws Exception {
|
||||||
// reset and serialize workspace providers
|
// reset and serialize workspace providers
|
||||||
LanguageSettingsManager.setWorkspaceProviders(null);
|
LanguageSettingsManager.setWorkspaceProviders(null);
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
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
|
* 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
|
* invariants after each B-tree operation, and so are especially
|
||||||
* expensive and cpu hungry.
|
* expensive and cpu hungry.
|
||||||
*/
|
*/
|
||||||
|
@Tag(BaseTestCase5.SLOW_TEST_TAG)
|
||||||
public class BTreeExpensiveTests extends BTreeTests {
|
public class BTreeExpensiveTests extends BTreeTests {
|
||||||
|
|
||||||
public static Test suite() {
|
@Test
|
||||||
return suite(BTreeExpensiveTests.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBySortedSetMirror() throws Exception {
|
public void testBySortedSetMirror() throws Exception {
|
||||||
sortedMirrorTest(100);
|
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)
|
* N.B. Each of the following tests are quite expensive (i.e. > 10mins each on a 2Ghz machine)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testBySortedSetMirror1682762087() throws Exception {
|
public void testBySortedSetMirror1682762087() throws Exception {
|
||||||
System.out.println("1682762087 Full Checking");
|
System.out.println("1682762087 Full Checking");
|
||||||
trial(1682762087, true); // exposed bugs in 2a,b
|
trial(1682762087, true); // exposed bugs in 2a,b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testBySortedSetMirror322922974() throws Exception {
|
public void testBySortedSetMirror322922974() throws Exception {
|
||||||
System.out.println("322922974 Full Checking");
|
System.out.println("322922974 Full Checking");
|
||||||
trial(322922974, true); // exposed bugs in 3b(ii)
|
trial(322922974, true); // exposed bugs in 3b(ii)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testBySortedSetMirror_588448152() throws Exception {
|
public void testBySortedSetMirror_588448152() throws Exception {
|
||||||
System.out.println("-588448152 Full Checking");
|
System.out.println("-588448152 Full Checking");
|
||||||
trial(-588448152, true); // exposed root-delete-on-merge problems
|
trial(-588448152, true); // exposed root-delete-on-merge problems
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
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.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -22,22 +25,21 @@ import java.util.Random;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
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.BTree;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.ChunkCache;
|
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.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import junit.framework.Test;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test insertion/deletion of records of a mock record type in a B-tree.
|
* Test insertion/deletion of records of a mock record type in a B-tree.
|
||||||
*
|
*
|
||||||
* @author aferguso
|
* @author aferguso
|
||||||
*/
|
*/
|
||||||
public class BTreeTests extends BaseTestCase {
|
public class BTreeTests extends BaseTestCase5 {
|
||||||
private static int DEBUG = 0;
|
private static int DEBUG = 0;
|
||||||
protected File dbFile;
|
protected File dbFile;
|
||||||
protected Database db;
|
protected Database db;
|
||||||
|
@ -45,10 +47,6 @@ public class BTreeTests extends BaseTestCase {
|
||||||
protected int rootRecord;
|
protected int rootRecord;
|
||||||
protected IBTreeComparator comparator;
|
protected IBTreeComparator comparator;
|
||||||
|
|
||||||
public static Test suite() {
|
|
||||||
return suite(BTreeTests.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
// setUp is not used since we need to parameterize this method,
|
// setUp is not used since we need to parameterize this method,
|
||||||
// and invoke it multiple times per Junit test
|
// and invoke it multiple times per Junit test
|
||||||
protected void init(int degree) throws Exception {
|
protected void init(int degree) throws Exception {
|
||||||
|
@ -66,6 +64,7 @@ public class BTreeTests extends BaseTestCase {
|
||||||
dbFile.deleteOnExit();
|
dbFile.deleteOnExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testBySortedSetMirrorLite() throws Exception {
|
public void testBySortedSetMirrorLite() throws Exception {
|
||||||
sortedMirrorTest(8);
|
sortedMirrorTest(8);
|
||||||
}
|
}
|
||||||
|
@ -91,6 +90,7 @@ public class BTreeTests extends BaseTestCase {
|
||||||
* and use TreeSet as a reference implementation to check behaviour against.
|
* and use TreeSet as a reference implementation to check behaviour against.
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testInsertion() throws Exception {
|
public void testInsertion() throws Exception {
|
||||||
Random seeder = new Random();
|
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.
|
* Bug 402177: BTree.insert should return the matching record if the new record was not inserted.
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testEquivalentRecordInsert_Bug402177() throws Exception {
|
public void testEquivalentRecordInsert_Bug402177() throws Exception {
|
||||||
init(8);
|
init(8);
|
||||||
try {
|
try {
|
||||||
|
@ -208,7 +209,7 @@ public class BTreeTests extends BaseTestCase {
|
||||||
BTMockRecord btValue = new BTMockRecord(record, db);
|
BTMockRecord btValue = new BTMockRecord(record, db);
|
||||||
if (i.hasNext()) {
|
if (i.hasNext()) {
|
||||||
Integer exp = ((Integer) i.next());
|
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++;
|
k++;
|
||||||
} else {
|
} else {
|
||||||
fail("Sizes different");
|
fail("Sizes different");
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class PDOMTestSuite extends TestSuite {
|
||||||
suite.addTest(IncludesTests.suite());
|
suite.addTest(IncludesTests.suite());
|
||||||
suite.addTest(OverloadsWithinSingleTUTests.suite());
|
suite.addTest(OverloadsWithinSingleTUTests.suite());
|
||||||
suite.addTest(OverloadsWithinCommonHeaderTests.suite());
|
suite.addTest(OverloadsWithinCommonHeaderTests.suite());
|
||||||
suite.addTest(BTreeTests.suite());
|
// Test converted to JUnit5: suite.addTest(BTreeTests.suite());
|
||||||
suite.addTest(PDOMStringSetTests.suite());
|
suite.addTest(PDOMStringSetTests.suite());
|
||||||
suite.addTest(PDOMTagIndexTests.suite());
|
suite.addTest(PDOMTagIndexTests.suite());
|
||||||
suite.addTest(FilesOnReindexTests.suite());
|
suite.addTest(FilesOnReindexTests.suite());
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.eclipse.cdt.core.suite;
|
package org.eclipse.cdt.core.suite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.cdescriptor.tests.CDescriptorOldTests;
|
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.envvar.IEnvironmentVariableManagerTests;
|
||||||
import org.eclipse.cdt.core.internal.efsextension.tests.EFSExtensionTests;
|
import org.eclipse.cdt.core.internal.efsextension.tests.EFSExtensionTests;
|
||||||
import org.eclipse.cdt.core.internal.errorparsers.tests.ErrorParserTestSuite;
|
import org.eclipse.cdt.core.internal.errorparsers.tests.ErrorParserTestSuite;
|
||||||
|
@ -77,7 +76,7 @@ public class AutomatedIntegrationSuite extends TestSuite {
|
||||||
|
|
||||||
// Has intermittent failures
|
// Has intermittent failures
|
||||||
if (System.getProperty("cdt.skip.known.test.failures") == null) {
|
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(AllConstexprEvalTestSuite.suite());
|
||||||
suite.addTest(ParserTestSuite.suite());
|
suite.addTest(ParserTestSuite.suite());
|
||||||
|
|
|
@ -43,14 +43,30 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.api.TestInfo;
|
import org.junit.jupiter.api.TestInfo;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
import junit.framework.TestResult;
|
import junit.framework.TestResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BaseTestCase for JUnit5.
|
* BaseTestCase for JUnit5.
|
||||||
*/
|
*/
|
||||||
public abstract class BaseTestCase5 {
|
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 DEFAULT_INDEXER_TIMEOUT_SEC = "10";
|
||||||
protected static final String INDEXER_TIMEOUT_PROPERTY = "indexer.timeout";
|
protected static final String INDEXER_TIMEOUT_PROPERTY = "indexer.timeout";
|
||||||
/**
|
/**
|
||||||
|
@ -241,6 +257,15 @@ public abstract class BaseTestCase5 {
|
||||||
fail("Test not migrated properly to JUnit5 yet.");
|
fail("Test not migrated properly to JUnit5 yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* 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.
|
* accidental override of the method is not left in subclasses when migrating.
|
||||||
|
|
Loading…
Add table
Reference in a new issue