mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 499471: Workaround indexer deadlock when tests running
See the bug for lots more details. Short summary is to prevent project from being deleted when indexer is still running to prevent the deadlock. Change-Id: Ie2523fcbacb3f8a15b43f107bd264069270c4028 Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
This commit is contained in:
parent
9982b67c76
commit
b34d04c0d5
10 changed files with 37 additions and 10 deletions
|
@ -66,7 +66,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp();
|
||||
ResourceHelper.cleanUp(getName());
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
|
@ -508,7 +508,7 @@ public class IEnvironmentVariableManagerTests extends TestCase {
|
|||
// Save the project description
|
||||
CoreModel.getDefault().setProjectDescription(project, prjDesc);
|
||||
|
||||
ResourceHelper.cleanUp();
|
||||
ResourceHelper.cleanUp(getName());
|
||||
assertFalse(project.exists());
|
||||
ResourceHelper.createCDTProjectWithConfig("envProject");
|
||||
assertTrue(project.exists());
|
||||
|
|
|
@ -98,7 +98,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
|
|||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp();
|
||||
ResourceHelper.cleanUp(getName());
|
||||
fProject = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
|
|||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp();
|
||||
ResourceHelper.cleanUp(getName());
|
||||
fProject = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ public class RegexErrorParserTests extends TestCase {
|
|||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp();
|
||||
ResourceHelper.cleanUp(getName());
|
||||
fProject = null;
|
||||
|
||||
ErrorParserManager.setUserDefinedErrorParsers(null);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class FindProgramLocationTest extends TestCase {
|
|||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp();
|
||||
ResourceHelper.cleanUp(getName());
|
||||
}
|
||||
|
||||
public void testCornerCases() throws CoreException, IOException {
|
||||
|
|
|
@ -37,7 +37,7 @@ public class StorableCdtVariablesTest extends TestCase {
|
|||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp();
|
||||
ResourceHelper.cleanUp(getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,7 +76,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
|
|||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp();
|
||||
ResourceHelper.cleanUp(getName());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -683,11 +683,38 @@ public class ResourceHelper {
|
|||
* This method removes *all* Workspace IResources and any external
|
||||
* files / folders created with the #createWorkspaceFile #createWorkspaceFolder
|
||||
* methods in this class
|
||||
*
|
||||
* @deprecated Use {@link #cleanUp(String)} instead so test name can be printed in diagnostics
|
||||
*/
|
||||
public static void cleanUp() throws CoreException, IOException {
|
||||
cleanUp("<unknown>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean-up any files created as part of a unit test.
|
||||
* This method removes *all* Workspace IResources and any external
|
||||
* files / folders created with the #createWorkspaceFile #createWorkspaceFolder
|
||||
* methods in this class
|
||||
*/
|
||||
public static void cleanUp(String testName) throws CoreException, IOException {
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
root.refreshLocal(IResource.DEPTH_INFINITE, NULL_MONITOR);
|
||||
|
||||
// Bug 499471: there is a race condition in the indexer when projects
|
||||
// are created and deleted quickly. Therefore, wait for the indexer
|
||||
// to be idle before deleting projects.
|
||||
if (!CCorePlugin.getIndexManager().isIndexerIdle()) {
|
||||
// the 2 second wait is very long in practice, when the race condition is
|
||||
// happening the total join time is just a few ms for most tests, and
|
||||
// up to 75 ms for a couple of tests on the HIPP
|
||||
boolean joinSuccess = CCorePlugin.getIndexManager().joinIndexer(2000, new NullProgressMonitor());
|
||||
if (!joinSuccess) {
|
||||
System.err.println(
|
||||
"Indexer did not stop runing, possible deadlock about to happen. Running test " + testName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Delete all external files & folders created using ResourceHelper
|
||||
for (String loc : externalFilesCreated) {
|
||||
File f = new File(loc);
|
||||
|
|
|
@ -101,7 +101,7 @@ public class BaseTestCase extends TestCase {
|
|||
for (File file; (file = filesToDeleteOnTearDown.pollLast()) != null;) {
|
||||
file.delete();
|
||||
}
|
||||
ResourceHelper.cleanUp();
|
||||
ResourceHelper.cleanUp(getName());
|
||||
TestScannerProvider.clear();
|
||||
super.tearDown();
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class BuildConsoleTests extends BaseUITestCase {
|
|||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
ResourceHelper.cleanUp();
|
||||
ResourceHelper.cleanUp(getName());
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue