From e9894fb35a3ed41949b2b829f50fe665624455a2 Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Wed, 9 Oct 2019 21:39:54 +0200 Subject: [PATCH] Fixed errors reporting in tearDown in performance tests --- .../org/jetbrains/kotlin/idea/perf/Stats.kt | 34 +++++++++++++------ .../idea/testFramework/gradleRoutines.kt | 15 -------- .../idea/testFramework/projectRoutines.kt | 10 ++++++ .../idea/testFramework/projectRoutines.kt.183 | 10 ++++++ .../idea/testFramework/projectRoutines.kt.191 | 10 ++++++ .../idea/testFramework/projectRoutines.kt.193 | 10 ++++++ 6 files changed, 63 insertions(+), 26 deletions(-) diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/Stats.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/Stats.kt index 06eb47bc001..e761dc79fc5 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/Stats.kt +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/Stats.kt @@ -167,6 +167,8 @@ class Stats( printTestFailed(stabilityName, "stability above $stabilityPercentage %") } } + } else { + printTimings(testName, printOnlyErrors = true, statInfoArray = statInfoArray) } } @@ -180,15 +182,20 @@ class Stats( private fun printTimings( prefix: String, statInfoArray: Array, + printOnlyErrors: Boolean = false, attemptFn: (Int) -> String = { attempt -> "#$attempt" } ) { for (statInfoIndex in statInfoArray.withIndex()) { val attempt = statInfoIndex.index val statInfo = statInfoIndex.value ?: continue val n = "$name: $prefix ${attemptFn(attempt)}" - printTestStarted(n) + val t = statInfo[ERROR_KEY] as? Throwable - if (t != null) printTestFinished(n, t) else { + if (t != null) { + printTestStarted(n) + printTestFinished(n, t) + } else if (!printOnlyErrors) { + printTestStarted(n) for ((k, v) in statInfo) { if (k == TEST_KEY) continue printStatValue("$n $k", v) @@ -217,6 +224,12 @@ class Stats( if (phaseData.testName != WARM_UP) { printWarmUpTimings(phaseData.testName, warmUpStatInfosArray) + } else { + printTimings( + phaseData.testName, + printOnlyErrors = true, + statInfoArray = warmUpStatInfosArray + ) { attempt -> "warm-up #$attempt" } } warmUpStatInfosArray.filterNotNull().map { it[ERROR_KEY] as? Throwable }.firstOrNull()?.let { throw it } @@ -237,7 +250,8 @@ class Stats( val phaseProfiler = createPhaseProfiler(phaseData, phaseName, attempt) val setUpMillis = measureTimeMillis { phaseData.setUp(testData) } - logMessage { "setup took $setUpMillis ms" } + val attemptName = "${phaseData.testName} #$attempt" + logMessage { "$attemptName setup took $setUpMillis ms" } val valueMap = HashMap(2 * PerformanceCounter.numberOfCounters + 1) statInfosArray[attempt] = valueMap @@ -255,26 +269,26 @@ class Stats( } } catch (t: Throwable) { - println("# error at ${phaseData.testName} #$attempt:") - t.printStackTrace() + logMessage(t) { "error at $attemptName" } valueMap[ERROR_KEY] = t + break } finally { try { val tearDownMillis = measureTimeMillis { phaseData.tearDown(testData) } - logMessage { "tearDown took $tearDownMillis ms" } + logMessage { "$attemptName tearDown took $tearDownMillis ms" } } catch (t: Throwable) { - println("# error at ${phaseData.testName} #$attempt:") - t.printStackTrace() + logMessage(t) { "error at tearDown of $attemptName" } valueMap[ERROR_KEY] = t + break } finally { PerformanceCounter.resetAllCounters() } } } } catch (t: Throwable) { - println("error at ${phaseData.testName}:") + logMessage(t) { "error at ${phaseData.testName}" } tcPrintErrors(phaseData.testName, listOf(t)) } return statInfosArray @@ -356,7 +370,6 @@ class Stats( println("error at $testName:") printStatValue(testName, -1) tcPrintErrors(testName, listOf(error)) - //printTestFinished(testName) } private fun printTestFailed(testName: String, details: String) { @@ -376,7 +389,6 @@ class Stats( printTestStarted(name) val (time, errors) = block() tcPrintErrors(name, errors) - //printTestFinished(name, time, includeStatValue = false) } private fun tcEscape(s: String) = s.replace("|", "||") diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/gradleRoutines.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/gradleRoutines.kt index b27c375dfa5..42c8d607b4b 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/gradleRoutines.kt +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/gradleRoutines.kt @@ -5,8 +5,6 @@ package org.jetbrains.kotlin.idea.testFramework -import com.intellij.ide.impl.ProjectUtil -import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManagerImpl import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil @@ -23,19 +21,6 @@ import kotlin.test.assertNotNull fun refreshGradleProject(projectPath: String, project: Project) { _importProject(projectPath, project) -// val gradleArguments = System.getProperty("kotlin.test.gradle.import.arguments") -// ExternalSystemUtil.refreshProjects( -// ImportSpecBuilder(project, GradleConstants.SYSTEM_ID) -// .forceWhenUptodate() -// .useDefaultCallback() -// .use(ProgressExecutionMode.MODAL_SYNC) -// .also { -// gradleArguments?.run(it::withArguments) -// } -// ) - - //ProjectUtil.updateLastProjectLocation(projectPath) - dispatchAllInvocationEvents() } diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt index f074c5d9e9f..22699ea3222 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt @@ -22,6 +22,8 @@ import com.intellij.testFramework.PlatformTestUtil import com.intellij.testFramework.runInEdtAndWait import com.intellij.util.ui.UIUtil import org.jetbrains.kotlin.idea.parameterInfo.HintType +import java.io.PrintWriter +import java.io.StringWriter fun commitAllDocuments() { val fileDocumentManager = FileDocumentManager.getInstance() @@ -104,4 +106,12 @@ fun replaceWithCustomHighlighter(parentDisposable: Disposable, fromImplementatio fun logMessage(message: () -> String) { println("-- ${message()}") +} + +fun logMessage(t: Throwable, message: () -> String) { + val writer = StringWriter() + PrintWriter(writer).use { + t.printStackTrace(it) + } + println("-- ${message()}:\n$writer") } \ No newline at end of file diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.183 b/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.183 index 748f2f81457..40908e67468 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.183 +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.183 @@ -24,6 +24,8 @@ import com.intellij.testFramework.runInEdtAndWait import com.intellij.util.ThrowableRunnable import com.intellij.util.ui.UIUtil import org.jetbrains.kotlin.idea.parameterInfo.HintType +import java.io.PrintWriter +import java.io.StringWriter fun commitAllDocuments() { ProjectManagerEx.getInstanceEx().openProjects.forEach { project -> @@ -89,4 +91,12 @@ fun replaceWithCustomHighlighter(parentDisposable: Disposable, fromImplementatio fun logMessage(message: () -> String) { println("-- ${message()}") +} + +fun logMessage(t: Throwable, message: () -> String) { + val writer = StringWriter() + PrintWriter(writer).use { + t.printStackTrace(it) + } + println("-- ${message()}:\n$writer") } \ No newline at end of file diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.191 b/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.191 index 5b42e2ea2ee..a86d4c45cc6 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.191 +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.191 @@ -27,6 +27,8 @@ import com.intellij.util.ui.UIUtil import org.jetbrains.kotlin.idea.parameterInfo.HintType import java.util.concurrent.TimeUnit import java.util.concurrent.TimeoutException +import java.io.PrintWriter +import java.io.StringWriter fun commitAllDocuments() { val fileDocumentManager = FileDocumentManager.getInstance() @@ -133,4 +135,12 @@ fun replaceWithCustomHighlighter(parentDisposable: Disposable, fromImplementatio fun logMessage(message: () -> String) { println("-- ${message()}") +} + +fun logMessage(t: Throwable, message: () -> String) { + val writer = StringWriter() + PrintWriter(writer).use { + t.printStackTrace(it) + } + println("-- ${message()}:\n$writer") } \ No newline at end of file diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.193 b/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.193 index cd837ba356e..327af90be68 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.193 +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/testFramework/projectRoutines.kt.193 @@ -23,6 +23,8 @@ import com.intellij.testFramework.runInEdtAndWait import com.intellij.util.ui.UIUtil import org.jetbrains.kotlin.idea.parameterInfo.HintType import java.nio.file.Paths +import java.io.PrintWriter +import java.io.StringWriter fun commitAllDocuments() { val fileDocumentManager = FileDocumentManager.getInstance() @@ -105,4 +107,12 @@ fun replaceWithCustomHighlighter(parentDisposable: Disposable, fromImplementatio fun logMessage(message: () -> String) { println("-- ${message()}") +} + +fun logMessage(t: Throwable, message: () -> String) { + val writer = StringWriter() + PrintWriter(writer).use { + t.printStackTrace(it) + } + println("-- ${message()}:\n$writer") } \ No newline at end of file