[Gradle, JS] Add custom log4js appender to KotlinKarma

#KT-38109 fixed
This commit is contained in:
Ilya Goncharov
2020-04-09 19:44:31 +03:00
parent 005ecc5f29
commit e1793c59be
2 changed files with 11 additions and 14 deletions
@@ -1,6 +1,6 @@
/* /*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* that can be found in the license/LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/ */
package org.jetbrains.kotlin.gradle.internal.testing package org.jetbrains.kotlin.gradle.internal.testing
@@ -85,6 +85,7 @@ internal open class TCServiceMessagesClient(
} }
} }
is TestSuiteFinished -> close(message.ts, getSuiteName(message)) is TestSuiteFinished -> close(message.ts, getSuiteName(message))
is Message -> regularText(message.text)
else -> Unit else -> Unit
} }
@@ -77,11 +77,14 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) :
it.appendln( it.appendln(
""" """
config.plugins = config.plugins || []; config.plugins = config.plugins || [];
config.plugins.push('karma-*'); // default
config.plugins.push('kotlin-test-js-runner/karma-kotlin-reporter.js'); config.plugins.push('kotlin-test-js-runner/karma-kotlin-reporter.js');
config.loggers = config.loggers || []; config.loggers = [
config.loggers.push({type: 'kotlin-test-js-runner/tc-log-appender.js'}); {
type: 'kotlin-test-js-runner/tc-log-appender.js',
layout: { type: 'pattern', pattern: '%[%d{DATE}:%p [%c]: %]%m' }
}
]
""".trimIndent() """.trimIndent()
) )
} }
@@ -448,11 +451,6 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) :
DEBUG -> log.debug(nonColoredMessage) DEBUG -> log.debug(nonColoredMessage)
} }
} }
// To provide additional information from Karma
if (SET_ENV_VAR.matches(text.trim())) {
log.error(text)
}
} }
private fun processFailedBrowsers(text: String) { private fun processFailedBrowsers(text: String) {
@@ -539,7 +537,5 @@ private const val INFO = "INFO"
private const val DEBUG = "DEBUG" private const val DEBUG = "DEBUG"
private const val LOG = "LOG" private const val LOG = "LOG"
private val KARMA_MESSAGE = "(?m)^.*\\d{2} \\d{2} \\d{4,} \\d{2}:\\d{2}:\\d{2}.\\d{3}:($ERROR|$WARN|$INFO|$DEBUG|$LOG) \\[.*]: (.*)\$" private val KARMA_MESSAGE = "^.*\\d{2} \\d{2} \\d{4,} \\d{2}:\\d{2}:\\d{2}.\\d{3}:(ERROR|WARN|INFO|DEBUG|LOG) \\[.*]: ([\\w\\W]*)\$"
.toRegex() .toRegex()
private val SET_ENV_VAR = "Please, set \"\\w+\" env variable.".toRegex()