Temp directories, which reside under project root replaced with java.io.tmpdir based ones.
This commit is contained in:
@@ -165,31 +165,16 @@ public class JetTestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void rmrf(File file) {
|
||||
if (file != null) {
|
||||
FileUtil.delete(file);
|
||||
}
|
||||
public static File tmpDirForTest(TestCase test) throws IOException {
|
||||
File answer = FileUtil.createTempDirectory(test.getClass().getSimpleName(), test.getName());
|
||||
deleteOnShutdown(answer);
|
||||
return answer;
|
||||
}
|
||||
|
||||
public static File tmpRoot() {
|
||||
return new File("tmp");
|
||||
}
|
||||
|
||||
public static File tmpDirForTest(TestCase test) {
|
||||
return new File(tmpRoot(), test.getClass().getSimpleName() + "/" + test.getName());
|
||||
}
|
||||
|
||||
public static File tmpDirForTest(Class<?> clazz) {
|
||||
return tmpDirForTest(clazz.getSimpleName());
|
||||
}
|
||||
|
||||
public static File tmpDirForTest(String name) {
|
||||
return new File(tmpRoot(), name);
|
||||
}
|
||||
|
||||
public static void recreateDirectory(File file) throws IOException {
|
||||
rmrf(file);
|
||||
mkdirs(file);
|
||||
public static File tmpDir(String name) throws IOException {
|
||||
File answer = FileUtil.createTempDirectory(name, "");
|
||||
deleteOnShutdown(answer);
|
||||
return answer;
|
||||
}
|
||||
|
||||
public static void deleteOnShutdown(File file) {
|
||||
|
||||
@@ -30,8 +30,7 @@ public class ForTestCompileStdlib {
|
||||
private static File stdlibJarFile;
|
||||
|
||||
private static File doCompile() throws Exception {
|
||||
File tmpDir = FileUtil.createTempDirectory("stdlibjar", "");
|
||||
JetTestUtils.deleteOnShutdown(tmpDir);
|
||||
File tmpDir = JetTestUtils.tmpDir("stdlibjar");
|
||||
|
||||
File jarFile = new File(tmpDir, "stdlib.jar");
|
||||
|
||||
@@ -119,7 +118,7 @@ public class ForTestCompileStdlib {
|
||||
|
||||
public static File stdlibJarForTests() {
|
||||
synchronized (ForTestCompileStdlib.class) {
|
||||
if (stdlibJarFile == null) {
|
||||
if (stdlibJarFile == null || !stdlibJarFile.exists()) {
|
||||
try {
|
||||
stdlibJarFile = doCompile();
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -66,8 +66,7 @@ public class CompileEnvironmentTest extends TestCase {
|
||||
File tempDir = FileUtil.createTempDirectory("compilerTest", "compilerTest");
|
||||
try {
|
||||
File out = new File(tempDir, "out");
|
||||
File stdlib = new File(tempDir, "stdlib.jar");
|
||||
FileUtil.copy(ForTestCompileStdlib.stdlibJarForTests(), stdlib);
|
||||
File stdlib = ForTestCompileStdlib.stdlibJarForTests();
|
||||
KotlinCompiler.exec("-src", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kt",
|
||||
"-output", out.getAbsolutePath(),
|
||||
"-stdlib", stdlib.getAbsolutePath());
|
||||
|
||||
@@ -16,7 +16,6 @@ public abstract class TestCaseWithTmpdir extends UsefulTestCase {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
tmpdir = JetTestUtils.tmpDirForTest(this);
|
||||
JetTestUtils.recreateDirectory(tmpdir);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user