From 3f7ca646a3bd5db82a5316b0106e3fc5f0113616 Mon Sep 17 00:00:00 2001 From: Vladislav Shishov Date: Tue, 11 Dec 2018 12:05:18 +0300 Subject: [PATCH] [gui-test] collect jvm errors --- .../testGuiFramework/framework/GuiTestSuite.kt | 13 +++++++++++++ .../intellij/testGuiFramework/impl/GuiTestCase.kt | 9 +++++++-- .../intellij/testGuiFramework/impl/GuiTestRule.kt | 7 ++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestSuite.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestSuite.kt index 88d4c9119599..31f03f031066 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestSuite.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/framework/GuiTestSuite.kt @@ -15,9 +15,11 @@ */ package com.intellij.testGuiFramework.framework +import com.intellij.testGuiFramework.launcher.GuiTestOptions import com.intellij.testGuiFramework.remote.IdeControl import org.junit.AfterClass import org.junit.BeforeClass +import java.io.File open class GuiTestSuite { @@ -31,6 +33,17 @@ open class GuiTestSuite { @JvmStatic fun tearDown() { IdeControl.closeIde() + collectJvmErrors() + GuiTestOptions.projectsDir.deleteRecursively() + } + + private fun collectJvmErrors() { + GuiTestOptions.projectsDir.walk() + .maxDepth(3) + .filter { it.name.startsWith("hs_err") } + .forEach { + it.copyTo(File(GuiTestPaths.failedTestScreenshotDir, it.name)) + } } } } diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt index 8001e58ae4e5..fc7bc23f1ebd 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestCase.kt @@ -33,6 +33,7 @@ import org.junit.rules.TestName import org.junit.runner.RunWith import java.awt.Component import java.io.File +import java.io.IOException import java.text.SimpleDateFormat import java.util.* import javax.swing.JDialog @@ -74,7 +75,7 @@ open class GuiTestCase { @JvmField val guiTestRule = GuiTestRule() - val projectsFolder: TemporaryFolder = guiTestRule.projectsFolder + val projectsFolder: File = guiTestRule.projectsFolder val settingsTitle: String = if (isMac()) "Preferences" else "Settings" // val defaultSettingsTitle: String = if (isMac()) "Default Preferences" else "Default Settings" @@ -92,7 +93,11 @@ open class GuiTestCase { val logActionsDuringTest = LogActionsDuringTest() val projectFolder: String by lazy { - projectsFolder.newFolder(testMethod.methodName).canonicalPath + val dir = File(projectsFolder, testMethod.methodName) + if (!dir.mkdirs()) { + throw IOException("project dir creation failed") + } + dir.canonicalPath } fun robot() = guiTestRule.robot() diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt index 2da285133f6e..fcf83548dbf8 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/impl/GuiTestRule.kt @@ -28,6 +28,7 @@ import com.intellij.testGuiFramework.impl.GuiTestUtilKt.computeOnEdt import com.intellij.testGuiFramework.impl.GuiTestUtilKt.ignoreComponentLookupException import com.intellij.testGuiFramework.impl.GuiTestUtilKt.runOnEdt import com.intellij.testGuiFramework.impl.GuiTestUtilKt.waitUntil +import com.intellij.testGuiFramework.launcher.GuiTestOptions import com.intellij.testGuiFramework.launcher.GuiTestOptions.screenRecorderJarDirPath import com.intellij.testGuiFramework.launcher.GuiTestOptions.testsToRecord import com.intellij.testGuiFramework.launcher.GuiTestOptions.videoDuration @@ -67,7 +68,7 @@ class GuiTestRule : TestRule { var CREATE_NEW_PROJECT_ACTION_NAME: String = "Create New Project" - val projectsFolder: TemporaryFolder = TemporaryFolder(File(FileUtil.getTempDirectory())) + val projectsFolder: File = File(GuiTestOptions.projectsDir, UUID.randomUUID().toString()) val LOG: Logger = Logger.getInstance(GuiTestRule::class.java.name) @@ -77,7 +78,7 @@ class GuiTestRule : TestRule { private var myTestShortName: String = "undefined" private var currentTestDateStart: Date = Date() - private val myRuleChain = RuleChain.outerRule(projectsFolder) + private val myRuleChain = RuleChain.emptyRuleChain() .around(myRobotTestRule) .around(myFatalErrorsFlusher) .around(IdeHandling()) @@ -460,7 +461,7 @@ class GuiTestRule : TestRule { } private fun getTestProjectDirPath(projectDirName: String): File { - return File(projectsFolder.root, projectDirName) + return File(projectsFolder, projectDirName) } fun cleanUpProjectForImport(projectPath: File) {