1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Bug 515560: Avoid indexer race condition by joining the indexer

Change-Id: I13bd33adba4eb790fae0c31d2c1378e19a59f4ff
This commit is contained in:
Jonah Graham 2017-04-24 08:52:40 +01:00 committed by Gerrit Code Review @ Eclipse.org
parent c8b23ec2d7
commit cc0955b823
22 changed files with 142 additions and 29 deletions

View file

@ -15,9 +15,12 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import java.io.IOException;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.make.core.MakeBuilder;
@ -134,7 +137,8 @@ public class StandardBuildTests extends TestCase {
*
* @param name
*/
private void removeProject(String name) {
private void removeProject(String name) throws CoreException, IOException {
ResourceHelper.cleanUp(getName());
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(name);
if (project.exists()) {
@ -149,7 +153,7 @@ public class StandardBuildTests extends TestCase {
/**
* Remove all the project information associated with the project used during test.
*/
public void testProjectCleanup() {
public void testProjectCleanup() throws CoreException, IOException {
removeProject(PROJECT_NAME);
}

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.ProblemMarkerInfo;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCPerFileBOPConsoleParser;
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
@ -64,6 +65,7 @@ public class GCCPerFileBOPConsoleParserTests extends BaseBOPConsoleParserTests {
if (fOutputParser != null) {
fOutputParser.shutdown();
}
ResourceHelper.cleanUp(getName());
if (fCProject != null) {
CProjectHelper.delete(fCProject);
}

View file

@ -16,6 +16,7 @@ import java.util.Map;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.MakeProjectNature;
@ -59,6 +60,7 @@ public class ScannerConfigDiscoveryTests extends BaseTestCase {
@Override
protected void tearDown() throws Exception {
ResourceHelper.cleanUp(getName());
StandardBuildTestHelper.removeProject("SCDC");
}

View file

@ -12,6 +12,7 @@ package org.eclipse.cdt.make.scannerdiscovery;
import java.io.ByteArrayInputStream;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
@ -42,6 +43,7 @@ public class ScannerConfigProfileTests extends BaseTestCase {
@Override
protected void tearDown() throws Exception {
ResourceHelper.cleanUp(getName());
StandardBuildTestHelper.removeProject("SCDC");
}

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@ -68,6 +69,7 @@ public abstract class AbstractBuilderTest extends TestCase {
@Override
protected void tearDown() throws Exception {
super.tearDown();
ResourceHelper.cleanUp(getName());
// Bug 327126 Stop the indexer before tearing down so we don't deadlock
Job.getJobManager().cancel(CCorePlugin.getPDOMManager());
Job.getJobManager().join(CCorePlugin.getPDOMManager(), null);

View file

@ -32,6 +32,7 @@ import junit.framework.TestCase;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
@ -214,6 +215,7 @@ public class ManagedBuildTestHelper {
* @param name
*/
static public void removeProject(String name) {
ResourceHelper.joinIndexerBeforeCleanup(ManagedBuildTestHelper.class.getName());
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
final IProject project = root.getProject(name);
if (project.exists()) {

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.language.settings.providers.ScannerDiscoveryLegacySu
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@ -49,6 +50,7 @@ public class CfgScannerConfigProfileManagerTests extends BaseTestCase {
@Override
protected void tearDown() throws Exception {
ResourceHelper.cleanUp(getName());
ManagedBuildTestHelper.removeProject(fProject.getName());
}

View file

@ -28,6 +28,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildIOType;
@ -854,6 +855,7 @@ public class BuildDescriptionModelTests extends TestCase {
@Override
protected void tearDown() throws Exception {
ResourceHelper.cleanUp(getName());
fCleaner.run();
if(DbgUtil.DEBUG)
DbgUtil.flush();

View file

@ -29,6 +29,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
@ -315,6 +316,7 @@ public class BuildSystem40Tests extends TestCase {
//deletion is performed in case if no fail occured
for(int i = 0; i < projects.length; i++){
try {
ResourceHelper.cleanUp(getName());
projects[i].delete(true, null);
assertNull(mngr.getProjectDescription(projects[i]));
assertNull(mngr.getProjectDescription(projects[i], false));
@ -442,6 +444,7 @@ public class BuildSystem40Tests extends TestCase {
//deletion is performed in case if no fail occured
for(int i = 0; i < projects.length; i++){
ResourceHelper.cleanUp(getName());
projects[i].delete(true, null);
assertNull(mngr.getProjectDescription(projects[i]));
assertNull(mngr.getProjectDescription(projects[i], false));

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
@ -302,6 +303,7 @@ public class ManagedBuildCoreTests20 extends TestCase {
ManagedBuildManager.saveBuildInfo(project, true);
ManagedBuildManager.removeBuildInfo(project);
try {
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
} catch (CoreException e) {
fail("Failed on project close: " + e.getLocalizedMessage());
@ -474,6 +476,7 @@ public class ManagedBuildCoreTests20 extends TestCase {
// Save, close, reopen and test again
ManagedBuildManager.saveBuildInfo(project, false);
ManagedBuildManager.removeBuildInfo(project);
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
project.open(null);
@ -612,6 +615,7 @@ public class ManagedBuildCoreTests20 extends TestCase {
ManagedBuildManager.saveBuildInfo(project, true);
ManagedBuildManager.removeBuildInfo(project);
try {
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
} catch (CoreException e) {
fail("Failed on project close: " + e.getLocalizedMessage());
@ -1709,7 +1713,8 @@ public class ManagedBuildCoreTests20 extends TestCase {
/**
* Remove all the project information associated with the project used during test.
*/
public void cleanup() {
public void cleanup() throws CoreException, IOException {
ResourceHelper.cleanUp(getName());
removeProject(projectName);
removeProject(projectName2);
}
@ -1831,6 +1836,7 @@ public class ManagedBuildCoreTests20 extends TestCase {
ManagedBuildManager.saveBuildInfo(project, true);
ManagedBuildManager.removeBuildInfo(project);
try {
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
} catch (CoreException e) {
fail("Failed on error parser project close: " + e.getLocalizedMessage());
@ -1901,6 +1907,7 @@ public class ManagedBuildCoreTests20 extends TestCase {
// Save, close, reopen and test again
ManagedBuildManager.saveBuildInfo(project, false);
ManagedBuildManager.removeBuildInfo(project);
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
project.open(null);

View file

@ -17,6 +17,7 @@ import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
@ -276,7 +277,7 @@ public class ManagedBuildCoreTests_SharedToolOptions extends TestCase {
* Sets up the test environment for a project created from the
* default project
*/
private void setupProject() throws Exception {
private IProject setupProject() throws Exception {
// The assertCorrectId() call needs to be set up
testExtensionElements = false;
@ -307,6 +308,8 @@ public class ManagedBuildCoreTests_SharedToolOptions extends TestCase {
testProject = newProject.getProjectType();
IConfiguration config = testProject.getConfiguration(configID);
testConfig = newProject.createConfiguration(config, configID + ".12345678");
return project;
}
/**
@ -553,12 +556,17 @@ public class ManagedBuildCoreTests_SharedToolOptions extends TestCase {
public void testConfiguration() throws Exception {
// Set up the environment
setupProject();
IProject project = setupProject();
try {
setupTestEnvironment();
// Rerun the other tests, without setting the test up again
testIsSetup = true;
testIcons();
testValueHandlers();
testOptions();
} finally {
ResourceHelper.cleanUp(getName());
project.delete(true, new NullProgressMonitor());
}
}
}

View file

@ -15,6 +15,7 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
@ -86,6 +87,13 @@ public class ManagedBuildEnvironmentTests extends TestCase {
return suite;
}
@Override
protected void tearDown() throws Exception {
ResourceHelper.addResourceCreated(proj);
ResourceHelper.cleanUp(getName());
super.tearDown();
}
// Checking behaviour when vars are not defined (except system)
public void testEnvNotDef(){
doInit();

View file

@ -22,6 +22,7 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
@ -105,6 +106,13 @@ public class ManagedBuildMacrosTests extends TestCase {
return suite;
}
@Override
protected void tearDown() throws Exception {
ResourceHelper.addResourceCreated(proj);
ResourceHelper.cleanUp(getName());
super.tearDown();
}
/**
* testMacroConf()
*/

View file

@ -15,6 +15,7 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
@ -34,6 +35,13 @@ public class ManagedBuildTCSupportedTest extends TestCase {
return suite;
}
@Override
protected void tearDown() throws Exception {
ResourceHelper.addResourceCreated(ManagedBuildMacrosTests.proj);
ResourceHelper.cleanUp(getName());
super.tearDown();
}
/**
* testIsSupported() -
*/

View file

@ -164,5 +164,6 @@ public class PathConverterTest extends TestCase {
IPath path = entry.getIncludePath();
String pathText = path.toString() ;
assertEquals("Unexpected value for include path", "/usr/local/include", pathText);
ManagedBuildTestHelper.removeProject("pathconverter01");
}
}

View file

@ -12,11 +12,8 @@ package org.eclipse.cdt.managedbuilder.core.tests;
import java.io.ByteArrayInputStream;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
@ -46,6 +43,10 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
public class ResourceBuildCoreTests extends TestCase {
private static final boolean boolVal = true;
@ -71,6 +72,12 @@ public class ResourceBuildCoreTests extends TestCase {
return suite;
}
@Override
protected void tearDown() throws Exception {
ResourceHelper.cleanUp(getName());
super.tearDown();
}
/**
* Creates a couple of resource configurations.
* Checks whether the resource & project default build properties are same or not.
@ -255,6 +262,7 @@ public class ResourceBuildCoreTests extends TestCase {
assertNotSame(projDebugOptionValue, newResMainDebugOptionValue);
// Close and remove project.
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
removeProject(projectName);
}
@ -356,6 +364,7 @@ public class ResourceBuildCoreTests extends TestCase {
assertEquals(defaultResToolFlags,resetResToolFlags);
// Close and remove project.
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
removeProject(projectName);
}
@ -498,6 +507,7 @@ public class ResourceBuildCoreTests extends TestCase {
ManagedBuildManager.saveBuildInfo(project,false);
ManagedBuildManager.removeBuildInfo(project);
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
// Now reopen the project.
@ -566,6 +576,7 @@ public class ResourceBuildCoreTests extends TestCase {
assertEquals(resBarDebugVal,newResBarDebugVal);
// Close and remove project.
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
removeProject(projectName);
@ -612,6 +623,7 @@ public class ResourceBuildCoreTests extends TestCase {
* @param name
*/
private void removeProject(String name) {
ResourceHelper.joinIndexerBeforeCleanup(getName());
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(name);
if (project.exists()) {
@ -702,6 +714,7 @@ public class ResourceBuildCoreTests extends TestCase {
ManagedBuildManager.saveBuildInfo(project, true);
ManagedBuildManager.removeBuildInfo(project);
try {
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
} catch (CoreException e) {
fail("Failed on project close: " + e.getLocalizedMessage());
@ -918,6 +931,7 @@ public class ResourceBuildCoreTests extends TestCase {
assertEquals(1,resConfigs.length);
// Close and remove project.
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
removeProject(renamedProjectName2);
}

View file

@ -19,6 +19,7 @@ import junit.framework.TestCase;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.templateengine.TemplateEngine;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
@ -53,6 +54,7 @@ public class TestProcesses extends TestCase {
protected void tearDown() throws Exception {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
ResourceHelper.cleanUp(getName());
if (project.exists()) {
try {
ManagedBuildTestHelper.delete(CoreModel.getDefault().create(project));

View file

@ -21,6 +21,7 @@ import junit.framework.TestSuite;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
import org.eclipse.core.resources.IProject;
@ -83,6 +84,7 @@ public class BackwardCompatiblityTests extends TestCase {
@Override
protected void tearDown() throws Exception {
ResourceHelper.cleanUp(getName());
for(Iterator<IProject> iter = projList.iterator(); iter.hasNext();){
IProject proj = iter.next();
try {

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
@ -103,6 +104,7 @@ public class CProjectDescriptionSerializationTests extends TestCase {
// Persist the project
coreModel.setProjectDescription(project, des);
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
}
@ -145,6 +147,7 @@ public class CProjectDescriptionSerializationTests extends TestCase {
Assert.assertEquals(message, 2, configurations.length);
}
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
}
}
@ -207,6 +210,7 @@ public class CProjectDescriptionSerializationTests extends TestCase {
Assert.fail(e.getMessage());
}
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
}
}
@ -264,6 +268,7 @@ public class CProjectDescriptionSerializationTests extends TestCase {
}
// Close project
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
}

View file

@ -31,6 +31,7 @@ import org.eclipse.cdt.core.settings.model.ICLibraryFileEntry;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IOption;
@ -58,11 +59,13 @@ public class OptionStringListValueTests extends TestCase {
@Override
protected void tearDown() throws Exception {
ResourceHelper.cleanUp(getName());
}
public void testCfgDesEntries() throws Exception {
String projName = PROJ_NAME_PREFIX + "1";
IProject project = BuildSystemTestHelper.createProject(projName, null, "cdt.managedbuild.target.gnu30.exe");
ResourceHelper.addResourceCreated(project);
CoreModel model = CoreModel.getDefault();
ICProjectDescriptionManager mngr = model.getProjectDescriptionManager();
@ -111,6 +114,7 @@ public class OptionStringListValueTests extends TestCase {
public void testLibFiles() throws Exception {
String projName = PROJ_NAME_PREFIX + "2";
IProject project = BuildSystemTestHelper.createProject(projName, null, "lv.tests.ptype");
ResourceHelper.addResourceCreated(project);
CoreModel model = CoreModel.getDefault();
ICProjectDescriptionManager mngr = model.getProjectDescriptionManager();
@ -200,6 +204,7 @@ public class OptionStringListValueTests extends TestCase {
public void testOptions() throws Exception {
String projName = PROJ_NAME_PREFIX + "3";
IProject project = BuildSystemTestHelper.createProject(projName, null, "lv.tests.ptype");
ResourceHelper.addResourceCreated(project);
CoreModel model = CoreModel.getDefault();
ICProjectDescriptionManager mngr = model.getProjectDescriptionManager();

View file

@ -40,6 +40,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFileInfo;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
@ -174,6 +175,7 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
IWorkspace wsp = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = wsp.getRoot();
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.delete(false, true, new NullProgressMonitor());
project = root.getProject(projectName);
@ -331,6 +333,7 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
}
coreModel.setProjectDescription(project, des);
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.delete(false, true, new NullProgressMonitor());
project = root.getProject(projectName);
@ -376,6 +379,7 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
coreModel.setProjectDescription(project, des);
fEventChecker = null;
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.delete(false, true, new NullProgressMonitor());
project = root.getProject(projectName);
@ -463,6 +467,7 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
coreModel.setProjectDescription(project, des);
fEventChecker = null;
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.delete(true, true, new NullProgressMonitor());
}
@ -503,6 +508,7 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
IWorkspace wsp = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = wsp.getRoot();
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.delete(false, true, new NullProgressMonitor());
project = root.getProject(projectName);
@ -559,6 +565,7 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
cfgDes = des.getConfigurations()[0];
checkArrays(cfgDes.getSourceEntries(), s);
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.delete(true, true, new NullProgressMonitor());
}
@ -722,6 +729,7 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
assertEquals(cprojectFileStamp, cprojectFile.lastModified());
// verify that closing/reopening the project preserves active configuration and does not touch project-model files
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.close(null);
project.open(null);
des = coreModel.getProjectDescription(project);
@ -731,6 +739,7 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
assertEquals(cprojectFileStamp, cprojectFile.lastModified());
// verify that deleting/reimporting the project resets active configuration but does not touch project-model files
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.delete(false, true, null);
project.create(null);
project.open(null);
@ -747,6 +756,7 @@ public class ProjectModelTests extends TestCase implements IElementChangedListen
}
finally {
if(project != null)
ResourceHelper.joinIndexerBeforeCleanup(getName());
project.delete(true, null);
}
}

View file

@ -700,19 +700,7 @@ public class ResourceHelper {
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);
}
}
joinIndexerBeforeCleanup(testName);
// Delete all external files & folders created using ResourceHelper
@ -736,6 +724,22 @@ public class ResourceHelper {
resourcesCreated.clear();
}
public static void joinIndexerBeforeCleanup(String testName) {
// 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);
}
}
}
private static void waitForProjectRefreshToFinish() {
try {
// CDT opens the Project with BACKGROUND_REFRESH enabled which causes the
@ -769,4 +773,14 @@ public class ResourceHelper {
}
f.delete();
}
/**
* Notify {@link ResourceHelper} that given resource should be removed in
* {@link #cleanUp(String)}.
*/
public static void addResourceCreated(IResource resource) {
if (resource != null) {
resourcesCreated.add(resource);
}
}
}