Allow tests to be run in parallel.
This commit is contained in:
committed by
max-kammerer
parent
ca0e66bafc
commit
21d81f353c
+5
-1
@@ -22,7 +22,11 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractForeignAnnotationsNoAnnotationInClasspathTest : AbstractForeignAnnotationsTest() {
|
||||
private val compiledJavaPath = KotlinTestUtils.tmpDir("java-compiled-files")
|
||||
// This should be executed after setUp runs, since setUp changes the root folder
|
||||
// for temporary files.
|
||||
private val compiledJavaPath by lazy {
|
||||
KotlinTestUtils.tmpDir("java-compiled-files")
|
||||
}
|
||||
|
||||
override fun getExtraClasspath(): List<File> {
|
||||
val foreignAnnotations = createJarWithForeignAnnotations()
|
||||
|
||||
-7
@@ -43,13 +43,6 @@ public abstract class KotlinMultiFileTestWithJava<M, F> extends KtUsefulTestCase
|
||||
coroutinesPackage = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if (javaFilesDir != null) FileUtil.delete(javaFilesDir);
|
||||
if (kotlinSourceRoot != null) FileUtil.delete(kotlinSourceRoot);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public class ModuleAndDependencies {
|
||||
final M module;
|
||||
final List<String> dependencies;
|
||||
|
||||
@@ -413,9 +413,7 @@ public class KotlinTestUtils {
|
||||
|
||||
@NotNull
|
||||
public static File tmpDirForTest(@NotNull String testClassName, @NotNull String testName) throws IOException {
|
||||
File answer = normalizeFile(FileUtil.createTempDirectory(testClassName, testName));
|
||||
deleteOnShutdown(answer);
|
||||
return answer;
|
||||
return normalizeFile(FileUtil.createTempDirectory(testClassName, testName, false));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -425,10 +423,7 @@ public class KotlinTestUtils {
|
||||
|
||||
@NotNull
|
||||
public static File tmpDir(String name) throws IOException {
|
||||
// We should use this form. otherwise directory will be deleted on each test.
|
||||
File answer = normalizeFile(FileUtil.createTempDirectory(new File(System.getProperty("java.io.tmpdir")), name, ""));
|
||||
deleteOnShutdown(answer);
|
||||
return answer;
|
||||
return normalizeFile(FileUtil.createTempDirectory(name, "", false));
|
||||
}
|
||||
|
||||
private static File normalizeFile(File file) throws IOException {
|
||||
@@ -438,18 +433,6 @@ public class KotlinTestUtils {
|
||||
return file.getCanonicalFile();
|
||||
}
|
||||
|
||||
private static void deleteOnShutdown(File file) {
|
||||
if (filesToDelete.isEmpty()) {
|
||||
ShutDownTracker.getInstance().registerShutdownTask(() -> {
|
||||
for (File victim : filesToDelete) {
|
||||
FileUtil.delete(victim);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
filesToDelete.add(file);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static KtFile createFile(@NotNull @NonNls String name, @NotNull String text, @NotNull Project project) {
|
||||
String shortName = name.substring(name.lastIndexOf('/') + 1);
|
||||
|
||||
+6
-7
@@ -76,7 +76,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
private static final String ourPathToKeep = null;
|
||||
private final List<String> myPathsToKeep = new ArrayList<>();
|
||||
|
||||
private String myTempDir;
|
||||
private File myTempDir;
|
||||
|
||||
static {
|
||||
// Radar #5755208: Command line Java applications need a way to launch without a Dock icon.
|
||||
@@ -100,8 +100,8 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
String testName = FileUtil.sanitizeFileName(getTestName(true));
|
||||
if (StringUtil.isEmptyOrSpaces(testName)) testName = "";
|
||||
testName = new File(testName).getName(); // in case the test name contains file separators
|
||||
myTempDir = new File(ORIGINAL_TEMP_DIR, TEMP_DIR_MARKER + testName).getPath();
|
||||
FileUtil.resetCanonicalTempPathCache(myTempDir);
|
||||
myTempDir = FileUtil.createTempDirectory(TEMP_DIR_MARKER, testName, false);
|
||||
FileUtil.resetCanonicalTempPathCache(myTempDir.getPath());
|
||||
boolean isStressTest = isStressTest();
|
||||
ApplicationInfoImpl.setInStressTest(isStressTest);
|
||||
// turn off Disposer debugging for performance tests
|
||||
@@ -119,7 +119,7 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
Disposer.setDebugMode(oldDisposerDebug);
|
||||
FileUtil.resetCanonicalTempPathCache(ORIGINAL_TEMP_DIR);
|
||||
if (hasTmpFilesToKeep()) {
|
||||
File[] files = new File(myTempDir).listFiles();
|
||||
File[] files = myTempDir.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (!shouldKeepTmpFile(file)) {
|
||||
@@ -127,9 +127,8 @@ public abstract class KtUsefulTestCase extends TestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
FileUtil.delete(new File(myTempDir));
|
||||
} else {
|
||||
FileUtil.delete(myTempDir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user