From 61e9d13fbd6d2c439c6506efa19060045badd3ce Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Tue, 14 Apr 2020 18:38:43 +0300 Subject: [PATCH] [Gradle, JS] Save stack trace for nodejs errors #KT-38109 fixed --- .../targets/js/testing/karma/KotlinKarma.kt | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt index b31d1e9fcd4..6ae4189a874 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt @@ -425,6 +425,8 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : private val failedBrowsers: MutableList = mutableListOf() + private var previousLine: String = "" + override fun printNonTestOutput(text: String, type: String?) { val value = text.trimEnd() progressLogger.progress(value) @@ -435,21 +437,30 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : private fun parseConsole(text: String, type: String?) { - var actualText = text + val actualType = if (text.trim().startsWith("at ")) { + parseConsole(previousLine, ERROR) + previousLine = "" + ERROR + } else { + previousLine = text + type + } val launcherMessage = KARMA_LAUNCHER_MESSAGE.matchEntire(text) - if (launcherMessage != null) { + val actualText = if (launcherMessage != null) { val (message) = launcherMessage.destructured - actualText = message - when (type?.toLowerCase()) { + when (actualType?.toLowerCase()) { WARN, ERROR -> { processFailedBrowsers(text) } } + message + } else { + text } - type?.let { log.processLogMessage(actualText, it) } + actualType?.let { log.processLogMessage(actualText, it) } } private fun processFailedBrowsers(text: String) {