Fix IDE related test problems after adding ability to run test in parallel in compiler configuration
This commit is contained in:
@@ -426,6 +426,13 @@ public class KotlinTestUtils {
|
|||||||
return normalizeFile(FileUtil.createTempDirectory(name, "", false));
|
return normalizeFile(FileUtil.createTempDirectory(name, "", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static File tmpDirForReusableLibrary(String name) throws IOException {
|
||||||
|
File answer = normalizeFile(FileUtil.createTempDirectory(new File(System.getProperty("java.io.tmpdir")), name, ""));
|
||||||
|
deleteOnShutdown(answer);
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
|
||||||
private static File normalizeFile(File file) throws IOException {
|
private static File normalizeFile(File file) throws IOException {
|
||||||
// Get canonical file to be sure that it's the same as inside the compiler,
|
// Get canonical file to be sure that it's the same as inside the compiler,
|
||||||
// for example, on Windows, if a canonical path contains any space from FileUtil.createTempDirectory we will get
|
// for example, on Windows, if a canonical path contains any space from FileUtil.createTempDirectory we will get
|
||||||
@@ -433,6 +440,18 @@ public class KotlinTestUtils {
|
|||||||
return file.getCanonicalFile();
|
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
|
@NotNull
|
||||||
public static KtFile createFile(@NotNull @NonNls String name, @NotNull String text, @NotNull Project project) {
|
public static KtFile createFile(@NotNull @NonNls String name, @NotNull String text, @NotNull Project project) {
|
||||||
String shortName = name.substring(name.lastIndexOf('/') + 1);
|
String shortName = name.substring(name.lastIndexOf('/') + 1);
|
||||||
|
|||||||
@@ -410,9 +410,7 @@ public class KotlinTestUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static File tmpDirForTest(@NotNull String testClassName, @NotNull String testName) throws IOException {
|
public static File tmpDirForTest(@NotNull String testClassName, @NotNull String testName) throws IOException {
|
||||||
File answer = normalizeFile(FileUtil.createTempDirectory(testClassName, testName));
|
return normalizeFile(FileUtil.createTempDirectory(testClassName, testName, false));
|
||||||
deleteOnShutdown(answer);
|
|
||||||
return answer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -422,7 +420,11 @@ public class KotlinTestUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static File tmpDir(String name) throws IOException {
|
public static File tmpDir(String name) throws IOException {
|
||||||
// We should use this form. otherwise directory will be deleted on each test.
|
return normalizeFile(FileUtil.createTempDirectory(name, "", false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static File tmpDirForReusableLibrary(String name) throws IOException {
|
||||||
File answer = normalizeFile(FileUtil.createTempDirectory(new File(System.getProperty("java.io.tmpdir")), name, ""));
|
File answer = normalizeFile(FileUtil.createTempDirectory(new File(System.getProperty("java.io.tmpdir")), name, ""));
|
||||||
deleteOnShutdown(answer);
|
deleteOnShutdown(answer);
|
||||||
return answer;
|
return answer;
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ object MockLibraryUtil {
|
|||||||
useJava9: Boolean = false
|
useJava9: Boolean = false
|
||||||
): File {
|
): File {
|
||||||
return compileLibraryToJar(
|
return compileLibraryToJar(
|
||||||
sourcesPath, KotlinTestUtils.tmpDir("testLibrary-" + jarName), jarName, addSources,allowKotlinSources, extraOptions, extraClasspath
|
sourcesPath, KotlinTestUtils.tmpDirForReusableLibrary("testLibrary-" + jarName), jarName, addSources, allowKotlinSources, extraOptions, extraClasspath
|
||||||
, useJava9)}
|
, useJava9)}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@@ -127,7 +127,7 @@ object MockLibraryUtil {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun compileJsLibraryToJar(sourcesPath: String, jarName: String, addSources: Boolean, extraOptions: List<String> = emptyList()): File {
|
fun compileJsLibraryToJar(sourcesPath: String, jarName: String, addSources: Boolean, extraOptions: List<String> = emptyList()): File {
|
||||||
val contentDir = KotlinTestUtils.tmpDir("testLibrary-" + jarName)
|
val contentDir = KotlinTestUtils.tmpDirForReusableLibrary("testLibrary-" + jarName)
|
||||||
|
|
||||||
val outDir = File(contentDir, "out")
|
val outDir = File(contentDir, "out")
|
||||||
val outputFile = File(outDir, jarName + ".js")
|
val outputFile = File(outDir, jarName + ".js")
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ abstract class AbstractScriptConfigurationTest : KotlinCompletionTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (configureConflictingModule in environment) {
|
if (configureConflictingModule in environment) {
|
||||||
val sharedLib = LocalFileSystem.getInstance().findFileByIoFile(environment["lib-classes"] as File)!!
|
val sharedLib = VfsUtil.findFileByIoFile(environment["lib-classes"] as File, true)!!
|
||||||
if (module == null) {
|
if (module == null) {
|
||||||
myModule = createTestModuleByName("mainModule")
|
myModule = createTestModuleByName("mainModule")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user