Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2016-08-10 11:37:03 +0000
committerJonah Graham2016-08-12 09:13:35 +0000
commitb34d04c0d587d829f4df413de94017739ad582b1 (patch)
tree16ddec3847de56aa41d325beb9f04403f22682f7
parent9982b67c7619ba47599fcb664c4a6d89792463f1 (diff)
downloadorg.eclipse.cdt-b34d04c0d587d829f4df413de94017739ad582b1.tar.gz
org.eclipse.cdt-b34d04c0d587d829f4df413de94017739ad582b1.tar.xz
org.eclipse.cdt-b34d04c0d587d829f4df413de94017739ad582b1.zip
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>
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/envvar/IEnvironmentVariableManagerTests.java4
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserEfsFileMatchingTest.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/FindProgramLocationTest.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/StorableCdtVariablesTest.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java2
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java27
-rw-r--r--core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java2
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/buildconsole/BuildConsoleTests.java2
10 files changed, 37 insertions, 10 deletions
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/envvar/IEnvironmentVariableManagerTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/envvar/IEnvironmentVariableManagerTests.java
index de9e26f3fc..46d0e8d715 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/envvar/IEnvironmentVariableManagerTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/envvar/IEnvironmentVariableManagerTests.java
@@ -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());
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserEfsFileMatchingTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserEfsFileMatchingTest.java
index 866a2c5bb8..12ab506369 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserEfsFileMatchingTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserEfsFileMatchingTest.java
@@ -98,7 +98,7 @@ public class ErrorParserEfsFileMatchingTest extends TestCase {
@Override
protected void tearDown() throws Exception {
- ResourceHelper.cleanUp();
+ ResourceHelper.cleanUp(getName());
fProject = null;
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java
index a7a148e4b1..5caaa6ca47 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/ErrorParserFileMatchingTest.java
@@ -102,7 +102,7 @@ public class ErrorParserFileMatchingTest extends TestCase {
@Override
protected void tearDown() throws Exception {
- ResourceHelper.cleanUp();
+ ResourceHelper.cleanUp(getName());
fProject = null;
}
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java
index 1d0cc28d5e..e3f05a8f71 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/errorparsers/tests/RegexErrorParserTests.java
@@ -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);
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/FindProgramLocationTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/FindProgramLocationTest.java
index 646a12292a..84ba3a441f 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/FindProgramLocationTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/FindProgramLocationTest.java
@@ -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 {
diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/StorableCdtVariablesTest.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/StorableCdtVariablesTest.java
index 24e4dd2d99..1325474085 100644
--- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/StorableCdtVariablesTest.java
+++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/utils/StorableCdtVariablesTest.java
@@ -37,7 +37,7 @@ public class StorableCdtVariablesTest extends TestCase {
@Override
protected void tearDown() throws Exception {
- ResourceHelper.cleanUp();
+ ResourceHelper.cleanUp(getName());
}
/**
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java
index 3412d3743d..b245251b6b 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java
@@ -76,7 +76,7 @@ public class CProjectDescriptionDeltaTests extends BaseTestCase{
@Override
protected void tearDown() throws Exception {
- ResourceHelper.cleanUp();
+ ResourceHelper.cleanUp(getName());
}
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java
index e3d39ef2ce..b9f48fc511 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/ResourceHelper.java
@@ -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);
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java
index 5d8c32c89b..e5071f2b9a 100644
--- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java
+++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java
@@ -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();
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/buildconsole/BuildConsoleTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/buildconsole/BuildConsoleTests.java
index 52f2dd25df..7165c617c2 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/buildconsole/BuildConsoleTests.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/buildconsole/BuildConsoleTests.java
@@ -54,7 +54,7 @@ public class BuildConsoleTests extends BaseUITestCase {
@Override
protected void tearDown() throws Exception {
- ResourceHelper.cleanUp();
+ ResourceHelper.cleanUp(getName());
super.tearDown();
}

Back to the top