Skip to content

Commit

Permalink
[Gradle, JS] Add custom log4js appender to KotlinKarma
Browse files Browse the repository at this point in the history
#KT-38109 fixed
  • Loading branch information
ilgonmic committed Apr 16, 2020
1 parent 005ecc5 commit e1793c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* 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
Expand Down Expand Up @@ -85,6 +85,7 @@ internal open class TCServiceMessagesClient(
}
}
is TestSuiteFinished -> close(message.ts, getSuiteName(message))
is Message -> regularText(message.text)
else -> Unit
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,14 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) :
it.appendln(
"""
config.plugins = config.plugins || [];
config.plugins.push('karma-*'); // default
config.plugins.push('kotlin-test-js-runner/karma-kotlin-reporter.js');
config.loggers = config.loggers || [];
config.loggers.push({type: 'kotlin-test-js-runner/tc-log-appender.js'});
config.loggers = [
{
type: 'kotlin-test-js-runner/tc-log-appender.js',
layout: { type: 'pattern', pattern: '%[%d{DATE}:%p [%c]: %]%m' }
}
]
""".trimIndent()
)
}
Expand Down Expand Up @@ -448,11 +451,6 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) :
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) {
Expand Down Expand Up @@ -539,7 +537,5 @@ private const val INFO = "INFO"
private const val DEBUG = "DEBUG"
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) \\[.*]: (.*)\$"
.toRegex()

private val SET_ENV_VAR = "Please, set \"\\w+\" env variable.".toRegex()
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()

0 comments on commit e1793c5

Please sign in to comment.