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:
parent
e8775e724f
commit
86490a11d7
2 changed files with 13 additions and 12 deletions
|
@ -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 temporary area.
|
||||||
* @return the location of a newly created directory in the systems temp. area
|
* Note that cleanup should be done with {@link ResourceHelper#cleanUp()}.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public static File freshDir() throws IOException {
|
public static File freshDir() throws IOException, CoreException {
|
||||||
File tempDir = new File(System.getProperty("java.io.tmpdir")).getCanonicalFile();
|
IPath folderPath = ResourceHelper.createTemporaryFolder();
|
||||||
for(int i=0; i<Integer.MAX_VALUE; i++) {
|
File folder = new File(folderPath.toOSString());
|
||||||
File candidate = new File(tempDir, "__testData/"+i);
|
Assert.assertTrue(folder.exists());
|
||||||
if(!candidate.exists()) {
|
Assert.assertTrue(folder.isDirectory());
|
||||||
candidate.mkdirs();
|
Assert.assertTrue(folder.canWrite());
|
||||||
return candidate;
|
|
||||||
}
|
return folder;
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
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.core.testplugin.TestScannerProvider;
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
||||||
|
@ -66,6 +67,7 @@ public class BaseTestCase extends TestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
|
ResourceHelper.cleanUp();
|
||||||
TestScannerProvider.clear();
|
TestScannerProvider.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue