extract file utils
This commit is contained in:
@@ -59,27 +59,6 @@ public class CompileJavaAgainstKotlinTest extends UsefulTestCase {
|
|||||||
jetCoreEnvironment.addToClasspath(new File(JetTestCaseBuilder.getHomeDirectory(), "compiler/testData/mockJDK-1.7/jre/lib/annotations.jar"));
|
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
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return ktFile.getName();
|
return ktFile.getName();
|
||||||
@@ -89,8 +68,7 @@ public class CompileJavaAgainstKotlinTest extends UsefulTestCase {
|
|||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
tmpdir = new File("tmp/" + this.getClass().getSimpleName() + "." + this.getName());
|
tmpdir = new File("tmp/" + this.getClass().getSimpleName() + "." + this.getName());
|
||||||
rmrf(tmpdir);
|
JetTestUtils.recreateDirectory(tmpdir);
|
||||||
mkdirs(tmpdir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import org.jetbrains.jet.util.slicedmap.ReadOnlySlice;
|
|||||||
import org.jetbrains.jet.util.slicedmap.SlicedMap;
|
import org.jetbrains.jet.util.slicedmap.SlicedMap;
|
||||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
@@ -128,4 +130,33 @@ public class JetTestUtils {
|
|||||||
public static BindingContext analyzeNamespace(@NotNull JetNamespace namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
public static BindingContext analyzeNamespace(@NotNull JetNamespace namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||||
return AnalyzerFacade.analyzeOneNamespaceWithJavaIntegration(namespace, 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ public class ReadClassDataTest extends UsefulTestCase {
|
|||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
tmpdir = new File("tmp/" + this.getClass().getSimpleName() + "." + this.getName());
|
tmpdir = new File("tmp/" + this.getClass().getSimpleName() + "." + this.getName());
|
||||||
rmrf(tmpdir);
|
JetTestUtils.recreateDirectory(tmpdir);
|
||||||
mkdirs(tmpdir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -74,27 +73,6 @@ public class ReadClassDataTest extends UsefulTestCase {
|
|||||||
Disposer.dispose(myTestRootDisposable);
|
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() {
|
private void createMockCoreEnvironment() {
|
||||||
jetCoreEnvironment = new JetCoreEnvironment(myTestRootDisposable);
|
jetCoreEnvironment = new JetCoreEnvironment(myTestRootDisposable);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user