1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

bug 309690: Error catching for CProjectHelper in cdt.core.tests

This commit is contained in:
Andrew Gvozdev 2010-04-22 18:12:26 +00:00
parent e8775e724f
commit 86490a11d7
2 changed files with 13 additions and 12 deletions

View file

@ -427,19 +427,18 @@ public class CProjectHelper {
}
/**
* Returns the location of a newly created directory in the systems temp. area.
* @return the location of a newly created directory in the systems temp. area
* @return the location of a newly created directory in temporary area.
* Note that cleanup should be done with {@link ResourceHelper#cleanUp()}.
* @throws IOException
* @throws CoreException
*/
public static File freshDir() throws IOException {
File tempDir = new File(System.getProperty("java.io.tmpdir")).getCanonicalFile();
for(int i=0; i<Integer.MAX_VALUE; i++) {
File candidate = new File(tempDir, "__testData/"+i);
if(!candidate.exists()) {
candidate.mkdirs();
return candidate;
}
}
return null;
public static File freshDir() throws IOException, CoreException {
IPath folderPath = ResourceHelper.createTemporaryFolder();
File folder = new File(folderPath.toOSString());
Assert.assertTrue(folder.exists());
Assert.assertTrue(folder.isDirectory());
Assert.assertTrue(folder.canWrite());
return folder;
}
}

View file

@ -31,6 +31,7 @@ import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.cdt.core.testplugin.ResourceHelper;
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
@ -66,6 +67,7 @@ public class BaseTestCase extends TestCase {
@Override
protected void tearDown() throws Exception {
ResourceHelper.cleanUp();
TestScannerProvider.clear();
}