mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Cleanup of temporary files created by tests.
Change-Id: Iaca298c1fd237787ea06cba5307cc473034ad314
This commit is contained in:
parent
2ca45300fe
commit
bfb4854e5d
5 changed files with 75 additions and 45 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2008, 2014 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.internal.tests;
|
package org.eclipse.cdt.core.internal.tests;
|
||||||
|
|
||||||
|
@ -16,9 +17,9 @@ import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
|
@ -30,7 +31,7 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public class ResourceLookupTests extends TestCase {
|
public class ResourceLookupTests extends BaseTestCase {
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return new TestSuite(ResourceLookupTests.class);
|
return new TestSuite(ResourceLookupTests.class);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +39,8 @@ public class ResourceLookupTests extends TestCase {
|
||||||
private IProject fProject;
|
private IProject fProject;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() {
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
fProject= root.getProject("reslookup_" + getName());
|
fProject= root.getProject("reslookup_" + getName());
|
||||||
}
|
}
|
||||||
|
@ -46,6 +48,7 @@ public class ResourceLookupTests extends TestCase {
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
fProject.delete(true, new NullProgressMonitor());
|
fProject.delete(true, new NullProgressMonitor());
|
||||||
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IFolder createFolder(IProject project, String filename) throws CoreException {
|
protected IFolder createFolder(IProject project, String filename) throws CoreException {
|
||||||
|
@ -214,7 +217,7 @@ public class ResourceLookupTests extends TestCase {
|
||||||
fProject.create(new NullProgressMonitor());
|
fProject.create(new NullProgressMonitor());
|
||||||
fProject.open(new NullProgressMonitor());
|
fProject.open(new NullProgressMonitor());
|
||||||
createFolder(fProject, "folder1");
|
createFolder(fProject, "folder1");
|
||||||
File f= File.createTempFile("extern", "h");
|
File f= createTempFile("extern", "h");
|
||||||
IPath location= Path.fromOSString(f.getAbsolutePath());
|
IPath location= Path.fromOSString(f.getAbsolutePath());
|
||||||
IFile file1= fProject.getFile("linked1");
|
IFile file1= fProject.getFile("linked1");
|
||||||
IFile file2= fProject.getFile("linked2.h");
|
IFile file2= fProject.getFile("linked2.h");
|
||||||
|
|
|
@ -14,10 +14,9 @@ package org.eclipse.cdt.internal.pdom.tests;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.Deque;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -64,7 +63,7 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
private static final String LOC_CYCINC1= "resources/pdomtests/generatePDOMTests/cyclicIncludes1";
|
private static final String LOC_CYCINC1= "resources/pdomtests/generatePDOMTests/cyclicIncludes1";
|
||||||
private static final String LOC_CYCINC2= "resources/pdomtests/generatePDOMTests/cyclicIncludes2";
|
private static final String LOC_CYCINC2= "resources/pdomtests/generatePDOMTests/cyclicIncludes2";
|
||||||
|
|
||||||
private static List toDeleteOnTearDown= new ArrayList();
|
private static Deque<ICProject> projectsToDeleteOnTearDown= new ArrayDeque<>();
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return suite(GeneratePDOMApplicationTest.class);
|
return suite(GeneratePDOMApplicationTest.class);
|
||||||
|
@ -74,17 +73,17 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
toDeleteOnTearDown.clear();
|
super.setUp();
|
||||||
target= File.createTempFile("test", "pdom");
|
projectsToDeleteOnTearDown.clear();
|
||||||
target.delete();
|
target = nonExistentTempFile("temp", "pdom");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
for(Iterator i= toDeleteOnTearDown.iterator(); i.hasNext(); ) {
|
for (ICProject cproject; (cproject = projectsToDeleteOnTearDown.pollLast()) != null;) {
|
||||||
ICProject cproject= (ICProject) i.next();
|
|
||||||
cproject.getProject().delete(true, new NullProgressMonitor());
|
cproject.getProject().delete(true, new NullProgressMonitor());
|
||||||
}
|
}
|
||||||
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBrokenExportProjectProvider1() throws Exception {
|
public void testBrokenExportProjectProvider1() throws Exception {
|
||||||
|
@ -149,7 +148,7 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
setExpectedNumberOfLoggedNonOKStatusObjects(1); // Expected failure: -source must be specified
|
setExpectedNumberOfLoggedNonOKStatusObjects(1); // Expected failure: -source must be specified
|
||||||
|
|
||||||
doGenerate(new String[] {
|
doGenerate(new String[] {
|
||||||
GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
|
GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
|
||||||
GeneratePDOMApplication.OPT_PROJECTPROVIDER, ExternalExportProjectProvider.class.getName()
|
GeneratePDOMApplication.OPT_PROJECTPROVIDER, ExternalExportProjectProvider.class.getName()
|
||||||
});
|
});
|
||||||
assertFalse(target.exists());
|
assertFalse(target.exists());
|
||||||
|
@ -190,12 +189,12 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
try {
|
try {
|
||||||
String fid = wpdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
|
String fid = wpdom.getProperty(IIndexFragment.PROPERTY_FRAGMENT_ID);
|
||||||
assertNotNull(fid);
|
assertNotNull(fid);
|
||||||
assertEquals("generate.pdom.tests.id."+getName(), fid); // check for id passed on command-line
|
assertEquals("generate.pdom.tests.id." + getName(), fid); // check for id passed on command-line
|
||||||
} finally {
|
} finally {
|
||||||
wpdom.releaseReadLock();
|
wpdom.releaseReadLock();
|
||||||
}
|
}
|
||||||
// depending on the timing the index of the temporary project is changed once or twice.
|
// depending on the timing the index of the temporary project is changed once or twice.
|
||||||
assertTrue("state is "+ stateCount[0], stateCount[0] == 2 || stateCount[0] == 4);
|
assertTrue("state is " + stateCount[0], stateCount[0] == 2 || stateCount[0] == 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExternalExportProjectProvider_SysIncludes() throws Exception {
|
public void testExternalExportProjectProvider_SysIncludes() throws Exception {
|
||||||
|
@ -232,10 +231,8 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
|
|
||||||
wpdom.acquireReadLock();
|
wpdom.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
assertEquals(1, wpdom.findBindings(new char[][] { "foo"
|
assertEquals(1, wpdom.findBindings(new char[][] { "foo".toCharArray() }, CLinkage, npm()).length);
|
||||||
.toCharArray() }, CLinkage, npm()).length);
|
assertEquals(0, wpdom.findBindings(new char[][] { "foo".toCharArray() }, CPPLinkage, npm()).length);
|
||||||
assertEquals(0, wpdom.findBindings(new char[][] { "foo"
|
|
||||||
.toCharArray() }, CPPLinkage, npm()).length);
|
|
||||||
} finally {
|
} finally {
|
||||||
wpdom.releaseReadLock();
|
wpdom.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
@ -263,8 +260,8 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
int b= bindings[0].getName().equals("A") ? 1 : 0;
|
int b= bindings[0].getName().equals("A") ? 1 : 0;
|
||||||
assertTrue(bindings[0] instanceof ICPPClassType);
|
assertTrue(bindings[0] instanceof ICPPClassType);
|
||||||
assertTrue(bindings[1] instanceof ICPPClassType);
|
assertTrue(bindings[1] instanceof ICPPClassType);
|
||||||
assertTrue(((ICPPClassType)bindings[1-b]).getBases().length==0);
|
assertTrue(((ICPPClassType)bindings[1 - b]).getBases().length == 0);
|
||||||
assertTrue(((ICPPClassType)bindings[b]).getBases().length==1);
|
assertTrue(((ICPPClassType)bindings[b]).getBases().length == 1);
|
||||||
} finally {
|
} finally {
|
||||||
wpdom.releaseReadLock();
|
wpdom.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
@ -272,7 +269,7 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
|
|
||||||
private WritablePDOM generatePDOM(String testProject, Class<?> provider, final int[] stateCount) throws Exception {
|
private WritablePDOM generatePDOM(String testProject, Class<?> provider, final int[] stateCount) throws Exception {
|
||||||
IIndexerStateListener listener= null;
|
IIndexerStateListener listener= null;
|
||||||
if(stateCount != null) {
|
if (stateCount != null) {
|
||||||
listener= new IIndexerStateListener() {
|
listener= new IIndexerStateListener() {
|
||||||
@Override
|
@Override
|
||||||
public void indexChanged(IIndexerStateEvent event) {
|
public void indexChanged(IIndexerStateEvent event) {
|
||||||
|
@ -290,13 +287,14 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
|
GeneratePDOMApplication.OPT_TARGET, target.getAbsolutePath(),
|
||||||
GeneratePDOMApplication.OPT_PROJECTPROVIDER, provider.getName(),
|
GeneratePDOMApplication.OPT_PROJECTPROVIDER, provider.getName(),
|
||||||
ExternalExportProjectProvider.OPT_SOURCE, baseDir,
|
ExternalExportProjectProvider.OPT_SOURCE, baseDir,
|
||||||
ExternalExportProjectProvider.OPT_FRAGMENT_ID, "generate.pdom.tests.id."+getName()
|
ExternalExportProjectProvider.OPT_FRAGMENT_ID, "generate.pdom.tests.id." + getName()
|
||||||
});
|
});
|
||||||
assertTrue(target.exists());
|
assertTrue(target.exists());
|
||||||
if(listener!=null) {
|
if (listener!=null) {
|
||||||
CCorePlugin.getIndexManager().removeIndexerStateListener(listener);
|
CCorePlugin.getIndexManager().removeIndexerStateListener(listener);
|
||||||
}
|
}
|
||||||
return new WritablePDOM(target, new URIRelativeLocationConverter(BASEURI), LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
|
return new WritablePDOM(target, new URIRelativeLocationConverter(BASEURI),
|
||||||
|
LanguageManager.getInstance().getPDOMLinkageFactoryMappings());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doGenerate(String[] args) throws CoreException {
|
private void doGenerate(String[] args) throws CoreException {
|
||||||
|
@ -329,8 +327,8 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
public static class TestProjectProvider2 implements IExportProjectProvider {
|
public static class TestProjectProvider2 implements IExportProjectProvider {
|
||||||
@Override
|
@Override
|
||||||
public ICProject createProject() throws CoreException {
|
public ICProject createProject() throws CoreException {
|
||||||
ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
|
ICProject cproject= CProjectHelper.createCCProject("test" + System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
|
||||||
toDeleteOnTearDown.add(cproject);
|
projectsToDeleteOnTearDown.add(cproject);
|
||||||
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
|
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
|
||||||
return cproject;
|
return cproject;
|
||||||
}
|
}
|
||||||
|
@ -345,8 +343,8 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
public static class TestProjectProvider3 implements IExportProjectProvider {
|
public static class TestProjectProvider3 implements IExportProjectProvider {
|
||||||
@Override
|
@Override
|
||||||
public ICProject createProject() throws CoreException {
|
public ICProject createProject() throws CoreException {
|
||||||
ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
|
ICProject cproject= CProjectHelper.createCCProject("test" + System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
|
||||||
toDeleteOnTearDown.add(cproject);
|
projectsToDeleteOnTearDown.add(cproject);
|
||||||
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
|
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
|
||||||
return cproject;
|
return cproject;
|
||||||
}
|
}
|
||||||
|
@ -363,8 +361,8 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
public static class TestProjectProvider4 implements IExportProjectProvider {
|
public static class TestProjectProvider4 implements IExportProjectProvider {
|
||||||
@Override
|
@Override
|
||||||
public ICProject createProject() throws CoreException {
|
public ICProject createProject() throws CoreException {
|
||||||
ICProject cproject= CProjectHelper.createCCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
|
ICProject cproject= CProjectHelper.createCCProject("test" + System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
|
||||||
toDeleteOnTearDown.add(cproject);
|
projectsToDeleteOnTearDown.add(cproject);
|
||||||
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
|
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ1);
|
||||||
return cproject;
|
return cproject;
|
||||||
}
|
}
|
||||||
|
@ -386,8 +384,8 @@ public class GeneratePDOMApplicationTest extends PDOMTestBase {
|
||||||
public static class TestProjectProvider5 implements IExportProjectProvider {
|
public static class TestProjectProvider5 implements IExportProjectProvider {
|
||||||
@Override
|
@Override
|
||||||
public ICProject createProject() throws CoreException {
|
public ICProject createProject() throws CoreException {
|
||||||
ICProject cproject= CProjectHelper.createCProject("test"+System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
|
ICProject cproject= CProjectHelper.createCProject("test" + System.currentTimeMillis(), null, IPDOMManager.ID_NO_INDEXER);
|
||||||
toDeleteOnTearDown.add(cproject);
|
projectsToDeleteOnTearDown.add(cproject);
|
||||||
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ3);
|
CProjectHelper.importSourcesFromPlugin(cproject, CTestPlugin.getDefault().getBundle(), LOC_TSTPRJ3);
|
||||||
return cproject;
|
return cproject;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
package org.eclipse.cdt.internal.pdom.tests;
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests bugs found in the PDOM
|
* Tests bugs found in the PDOM.
|
||||||
*/
|
*/
|
||||||
public class PDOMCPPBugsTest extends BaseTestCase {
|
public class PDOMCPPBugsTest extends BaseTestCase {
|
||||||
ICProject cproject;
|
ICProject cproject;
|
||||||
|
@ -58,7 +59,7 @@ public class PDOMCPPBugsTest extends BaseTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
cproject= CProjectHelper.createCCProject("PDOMBugsTest"+System.currentTimeMillis(), "bin", IPDOMManager.ID_FAST_INDEXER);
|
cproject= CProjectHelper.createCCProject("PDOMBugsTest" + System.currentTimeMillis(), "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
waitForIndexer(cproject);
|
waitForIndexer(cproject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +109,7 @@ public class PDOMCPPBugsTest extends BaseTestCase {
|
||||||
// this test is currently failing on the cdt test build machine, but
|
// this test is currently failing on the cdt test build machine, but
|
||||||
// not on my local linux or windows boxes.
|
// not on my local linux or windows boxes.
|
||||||
|
|
||||||
File tmp= new File(System.getProperty("java.io.tmpdir")+"/temp"+System.currentTimeMillis()+".pdom");
|
File tmp = nonExistentTempFile("temp", "pdom");
|
||||||
IIndexLocationConverter cvr= new ResourceContainerRelativeLocationConverter(cproject.getProject());
|
IIndexLocationConverter cvr= new ResourceContainerRelativeLocationConverter(cproject.getProject());
|
||||||
final PDOMManager pdomManager = CCoreInternals.getPDOMManager();
|
final PDOMManager pdomManager = CCoreInternals.getPDOMManager();
|
||||||
pdomManager.exportProjectPDOM(cproject, tmp, cvr, null);
|
pdomManager.exportProjectPDOM(cproject, tmp, cvr, null);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
package org.eclipse.cdt.internal.pdom.tests;
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ public class PDOMProviderTests extends PDOMTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLifeCycle() throws Exception {
|
public void testLifeCycle() throws Exception {
|
||||||
final File tempPDOM= File.createTempFile("foo", "bar");
|
final File tempPDOM= createTempFile("foo", "bar");
|
||||||
|
|
||||||
{
|
{
|
||||||
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
|
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
|
||||||
|
@ -124,7 +125,7 @@ public class PDOMProviderTests extends PDOMTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCommonSDK() throws Exception {
|
public void testCommonSDK() throws Exception {
|
||||||
final File tempPDOM= File.createTempFile("foo", "bar");
|
final File tempPDOM= createTempFile("foo", "bar");
|
||||||
|
|
||||||
{
|
{
|
||||||
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
|
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
|
||||||
|
@ -242,7 +243,7 @@ public class PDOMProviderTests extends PDOMTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testVersionMismatchOfExternalPDOM_178998() throws Exception {
|
public void testVersionMismatchOfExternalPDOM_178998() throws Exception {
|
||||||
final File tempPDOM= File.createTempFile("foo", "bar");
|
final File tempPDOM= createTempFile("foo", "bar");
|
||||||
|
|
||||||
{
|
{
|
||||||
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
|
ICProject cproject= CProjectHelper.createCCProject("foo" + System.currentTimeMillis(), null, IPDOMManager.ID_FAST_INDEXER);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2013 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2014 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,10 +12,14 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.testplugin.util;
|
package org.eclipse.cdt.core.testplugin.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Deque;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -62,6 +66,7 @@ public class BaseTestCase extends TestCase {
|
||||||
private boolean fExpectFailure;
|
private boolean fExpectFailure;
|
||||||
private int fBugNumber;
|
private int fBugNumber;
|
||||||
private int fExpectedLoggedNonOK;
|
private int fExpectedLoggedNonOK;
|
||||||
|
private Deque<File> filesToDeleteOnTearDown= new ArrayDeque<>();
|
||||||
|
|
||||||
public BaseTestCase() {
|
public BaseTestCase() {
|
||||||
super();
|
super();
|
||||||
|
@ -77,6 +82,7 @@ public class BaseTestCase extends TestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
CPPASTNameBase.sAllowRecursionBindings= false;
|
CPPASTNameBase.sAllowRecursionBindings= false;
|
||||||
CPPASTNameBase.sAllowNameComputation= false;
|
CPPASTNameBase.sAllowNameComputation= false;
|
||||||
CModelListener.sSuppressUpdateOfLastRecentlyUsed= true;
|
CModelListener.sSuppressUpdateOfLastRecentlyUsed= true;
|
||||||
|
@ -84,8 +90,29 @@ public class BaseTestCase extends TestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
|
for (File file; (file = filesToDeleteOnTearDown.pollLast()) != null;) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
ResourceHelper.cleanUp();
|
ResourceHelper.cleanUp();
|
||||||
TestScannerProvider.clear();
|
TestScannerProvider.clear();
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void deleteOnTearDown(File file) {
|
||||||
|
filesToDeleteOnTearDown.add(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected File createTempFile(String prefix, String suffix) throws IOException {
|
||||||
|
File file = File.createTempFile(prefix, suffix);
|
||||||
|
filesToDeleteOnTearDown.add(file);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected File nonExistentTempFile(String prefix, String suffix) {
|
||||||
|
File file= new File(System.getProperty("java.io.tmpdir"),
|
||||||
|
prefix + System.currentTimeMillis() + '.' + suffix);
|
||||||
|
filesToDeleteOnTearDown.add(file);
|
||||||
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static TestSuite suite(Class clazz) {
|
protected static TestSuite suite(Class clazz) {
|
||||||
|
@ -212,7 +239,7 @@ public class BaseTestCase extends TestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(TestResult result) {
|
public void run(TestResult result) {
|
||||||
if (!fExpectFailure || "true".equals(System.getProperty("SHOW_EXPECTED_FAILURES"))) {
|
if (!fExpectFailure || Boolean.parseBoolean(System.getProperty("SHOW_EXPECTED_FAILURES"))) {
|
||||||
super.run(result);
|
super.run(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue