From 4387862d2067d7ce6791760e7da0c0246a5e0f31 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 17 Sep 2019 17:09:41 +0300 Subject: [PATCH] Remap android home directory to allow parallel test execution (KT-33870) Using same directory for android (user home) leads to exception on Windows because of file lock: com.google.gson.JsonSyntaxException: java.io.IOException: The process cannot access the file because another process has locked a portion of the file at com.google.gson.Gson.fromJson(Gson.java:942) at com.google.gson.Gson.fromJson(Gson.java:865) at com.android.tools.analytics.AnalyticsSettings.loadSettingsData(AnalyticsSettings.kt:140) at com.android.tools.analytics.AnalyticsSettings.initialize(AnalyticsSettings.kt:211) at org.jetbrains.android.AndroidPlugin.initializeForNonStudio(AndroidPlugin.java:56) at org.jetbrains.android.AndroidPlugin.initComponent(AndroidPlugin.java:30) at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:503) at com.intellij.openapi.components.impl.ComponentManagerImpl.createComponents(ComponentManagerImpl.java:126) at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:411) at com.intellij.idea.IdeaTestApplication.a(IdeaTestApplication.java:114) at com.intellij.idea.IdeaTestApplication.getInstance(IdeaTestApplication.java:61) at com.intellij.idea.IdeaTestApplication.getInstance(IdeaTestApplication.java:54) at com.intellij.testFramework.LightPlatformTestCase.initApplication(LightPlatformTestCase.java:166) at com.intellij.testFramework.fixtures.impl.LightIdeaTestFixtureImpl.setUp(LightIdeaTestFixtureImpl.java:41) at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.lambda$setUp$27(CodeInsightTestFixtureImpl.java:1142) at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:18) at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:13) at com.intellij.testFramework.EdtTestUtilKt.runInEdtAndWait(EdtTestUtil.kt:63) at com.intellij.testFramework.EdtTestUtil$Companion.runInEdtAndWait(EdtTestUtil.kt:18) at com.intellij.testFramework.EdtTestUtil.runInEdtAndWait(EdtTestUtil.kt) at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.setUp(CodeInsightTestFixtureImpl.java:1141) at com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase.setUp(LightJavaCodeInsightFixtureTestCase.java:96) at org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase.setUp(KotlinLightCodeInsightFixtureTestCase.kt:66) at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:388) at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:18) at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:13) at com.intellij.testFramework.EdtTestUtilKt$runInEdtAndWait$3.run(EdtTestUtil.kt:67) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:433) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) Caused by: java.io.IOException: The process cannot access the file because another process has locked a portion of the file at sun.nio.ch.FileDispatcherImpl.read0(Native Method) at sun.nio.ch.FileDispatcherImpl.read(FileDispatcherImpl.java:61) at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) at sun.nio.ch.IOUtil.read(IOUtil.java:197) at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:159) at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:65) at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:109) at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) at java.io.InputStreamReader.read(InputStreamReader.java:184) at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1295) at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1333) at com.google.gson.stream.JsonReader.consumeNonExecutePrefix(JsonReader.java:1576) at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:534) at com.google.gson.stream.JsonReader.peek(JsonReader.java:425) at com.google.gson.Gson.fromJson(Gson.java:923) ... 41 more #KT-33870 Fixed --- .../test/IdeaSystemPropertiesForParallelRunConfigurator.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/IdeaSystemPropertiesForParallelRunConfigurator.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/test/IdeaSystemPropertiesForParallelRunConfigurator.kt index bf118d75c8b..47699a8ba22 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/IdeaSystemPropertiesForParallelRunConfigurator.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/IdeaSystemPropertiesForParallelRunConfigurator.kt @@ -18,6 +18,7 @@ object IdeaSystemPropertiesForParallelRunConfigurator { FileUtil.createTempDirectory(File(System.getProperty("java.io.tmpdir")), "testRoot", "GW$GRADLE_WORKER", false).path private val IDEA_SYSTEM = FileUtil.createTempDirectory(File(PROCESS_TMP_ROOT_FOLDER), "idea-system", "", false).path private val IDEA_CONFIG = FileUtil.createTempDirectory(File(PROCESS_TMP_ROOT_FOLDER), "idea-config", "", false).path + private val ANDROID_HOME = FileUtil.createTempDirectory(File(PROCESS_TMP_ROOT_FOLDER), ".android", "", false).path init { // UsefulTestCase temp dir construction could cause folder clash on parallel test execution: @@ -27,6 +28,7 @@ object IdeaSystemPropertiesForParallelRunConfigurator { System.setProperty("java.io.tmpdir", PROCESS_TMP_ROOT_FOLDER) System.setProperty(PROPERTY_SYSTEM_PATH, IDEA_SYSTEM) System.setProperty(PROPERTY_CONFIG_PATH, IDEA_CONFIG) + System.setProperty("ANDROID_SDK_HOME", ANDROID_HOME) } @JvmStatic