diff --git a/compiler/tests/org/jetbrains/jet/CompileJavaAgainstKotlinTest.java b/compiler/tests/org/jetbrains/jet/CompileJavaAgainstKotlinTest.java index 8b0cc8d0ff4..32fe6c20c93 100644 --- a/compiler/tests/org/jetbrains/jet/CompileJavaAgainstKotlinTest.java +++ b/compiler/tests/org/jetbrains/jet/CompileJavaAgainstKotlinTest.java @@ -59,27 +59,6 @@ public class CompileJavaAgainstKotlinTest extends UsefulTestCase { jetCoreEnvironment.addToClasspath(new File(JetTestCaseBuilder.getHomeDirectory(), "compiler/testData/mockJDK-1.7/jre/lib/annotations.jar")); } - private void mkdirs(File file) throws IOException { - if (file.isDirectory()) { - return; - } - if (!file.mkdirs()) { - throw new IOException(); - } - } - - private void rmrf(File file) { - if (file != null) { - File[] children = file.listFiles(); - if (children != null) { - for (File child : children) { - rmrf(child); - } - } - file.delete(); - } - } - @Override public String getName() { return ktFile.getName(); @@ -89,8 +68,7 @@ public class CompileJavaAgainstKotlinTest extends UsefulTestCase { protected void setUp() throws Exception { super.setUp(); tmpdir = new File("tmp/" + this.getClass().getSimpleName() + "." + this.getName()); - rmrf(tmpdir); - mkdirs(tmpdir); + JetTestUtils.recreateDirectory(tmpdir); } @Override diff --git a/compiler/tests/org/jetbrains/jet/JetTestUtils.java b/compiler/tests/org/jetbrains/jet/JetTestUtils.java index ed43b181be0..ab08e533763 100644 --- a/compiler/tests/org/jetbrains/jet/JetTestUtils.java +++ b/compiler/tests/org/jetbrains/jet/JetTestUtils.java @@ -13,6 +13,8 @@ import org.jetbrains.jet.util.slicedmap.ReadOnlySlice; import org.jetbrains.jet.util.slicedmap.SlicedMap; import org.jetbrains.jet.util.slicedmap.WritableSlice; +import java.io.File; +import java.io.IOException; import java.util.Collection; import java.util.Collections; @@ -128,4 +130,33 @@ public class JetTestUtils { public static BindingContext analyzeNamespace(@NotNull JetNamespace namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) { return AnalyzerFacade.analyzeOneNamespaceWithJavaIntegration(namespace, flowDataTraceFactory); } + + + public static void mkdirs(File file) throws IOException { + if (file.isDirectory()) { + return; + } + if (!file.mkdirs()) { + throw new IOException(); + } + } + + public static void rmrf(File file) { + if (file != null) { + File[] children = file.listFiles(); + if (children != null) { + for (File child : children) { + rmrf(child); + } + } + file.delete(); + } + } + + public static void recreateDirectory(File file) throws IOException { + rmrf(file); + mkdirs(file); + } + + } diff --git a/compiler/tests/org/jetbrains/jet/ReadClassDataTest.java b/compiler/tests/org/jetbrains/jet/ReadClassDataTest.java index e97ad3202cd..5deb55ba672 100644 --- a/compiler/tests/org/jetbrains/jet/ReadClassDataTest.java +++ b/compiler/tests/org/jetbrains/jet/ReadClassDataTest.java @@ -65,8 +65,7 @@ public class ReadClassDataTest extends UsefulTestCase { protected void setUp() throws Exception { super.setUp(); tmpdir = new File("tmp/" + this.getClass().getSimpleName() + "." + this.getName()); - rmrf(tmpdir); - mkdirs(tmpdir); + JetTestUtils.recreateDirectory(tmpdir); } @Override @@ -74,27 +73,6 @@ public class ReadClassDataTest extends UsefulTestCase { Disposer.dispose(myTestRootDisposable); } - private void mkdirs(File file) throws IOException { - if (file.isDirectory()) { - return; - } - if (!file.mkdirs()) { - throw new IOException(); - } - } - - private void rmrf(File file) { - if (file != null) { - File[] children = file.listFiles(); - if (children != null) { - for (File child : children) { - rmrf(child); - } - } - file.delete(); - } - } - private void createMockCoreEnvironment() { jetCoreEnvironment = new JetCoreEnvironment(myTestRootDisposable);