[Gradle, JS] Typed message for log type
#KT-38109 fixed #KT-38286 fixed
This commit is contained in:
+2
-2
@@ -85,7 +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)
|
is Message -> printNonTestOutput(message.text, message.attributes["type"])
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ internal open class TCServiceMessagesClient(
|
|||||||
afterMessage = false
|
afterMessage = false
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun printNonTestOutput(text: String) {
|
protected open fun printNonTestOutput(text: String, type: String? = null) {
|
||||||
print(text)
|
print(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
@@ -52,6 +52,7 @@ class TCServiceMessagesTestExecutor(
|
|||||||
spec.forkOptions.copyTo(exec)
|
spec.forkOptions.copyTo(exec)
|
||||||
exec.args = spec.args
|
exec.args = spec.args
|
||||||
exec.standardOutput = TCServiceMessageOutputStreamHandler(client, { spec.showSuppressedOutput() }, log)
|
exec.standardOutput = TCServiceMessageOutputStreamHandler(client, { spec.showSuppressedOutput() }, log)
|
||||||
|
exec.errorOutput = TCServiceMessageOutputStreamHandler(client, { spec.showSuppressedOutput() }, log)
|
||||||
execHandle = exec.build()
|
execHandle = exec.build()
|
||||||
|
|
||||||
lateinit var result: ExecResult
|
lateinit var result: ExecResult
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ internal open class JSServiceMessagesClient(
|
|||||||
settings: TCServiceMessagesClientSettings,
|
settings: TCServiceMessagesClientSettings,
|
||||||
log: Logger
|
log: Logger
|
||||||
) : TCServiceMessagesClient(results, settings, log) {
|
) : TCServiceMessagesClient(results, settings, log) {
|
||||||
override fun printNonTestOutput(text: String) {
|
override fun printNonTestOutput(text: String, type: String?) {
|
||||||
if (log.isDebugEnabled) {
|
if (log.isDebugEnabled) {
|
||||||
log.debug(text)
|
log.debug(text)
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-5
@@ -200,6 +200,17 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) :
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//language=ES6
|
||||||
|
it.appendln(
|
||||||
|
"""
|
||||||
|
// noinspection JSUnnecessarySemicolon
|
||||||
|
;(function(config) {
|
||||||
|
const tcErrorPlugin = require('kotlin-test-js-runner/tc-log-error-webpack');
|
||||||
|
config.plugins.push(new tcErrorPlugin(tcErrorPlugin))
|
||||||
|
})(config);
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
it.appendln(" return config;")
|
it.appendln(" return config;")
|
||||||
it.appendln("}")
|
it.appendln("}")
|
||||||
it.appendln()
|
it.appendln()
|
||||||
@@ -418,15 +429,17 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) :
|
|||||||
|
|
||||||
private val failedBrowsers: MutableList<String> = mutableListOf()
|
private val failedBrowsers: MutableList<String> = mutableListOf()
|
||||||
|
|
||||||
override fun printNonTestOutput(text: String) {
|
override fun printNonTestOutput(text: String, type: String?) {
|
||||||
val value = text.trimEnd()
|
val value = text.trimEnd()
|
||||||
progressLogger.progress(value)
|
progressLogger.progress(value)
|
||||||
|
|
||||||
parseConsole(value)
|
parseConsole(value, type)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseConsole(text: String) {
|
private fun parseConsole(text: String, type: String?) {
|
||||||
|
|
||||||
val result = KARMA_MESSAGE.matchEntire(text)
|
val result = KARMA_MESSAGE.matchEntire(text)
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
|
||||||
val (logLevel, message) = result.destructured
|
val (logLevel, message) = result.destructured
|
||||||
@@ -445,8 +458,20 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) :
|
|||||||
INFO, LOG -> log.info(nonColoredMessage)
|
INFO, LOG -> log.info(nonColoredMessage)
|
||||||
DEBUG -> log.debug(nonColoredMessage)
|
DEBUG -> log.debug(nonColoredMessage)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
super.printNonTestOutput(text)
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val nonColoredText = text.clearAnsiColor()
|
||||||
|
|
||||||
|
if (type == "error") {
|
||||||
|
log.error(nonColoredText)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "warn") {
|
||||||
|
log.warn(nonColoredText)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,13 @@ export default [
|
|||||||
format: 'cjs'
|
format: 'cjs'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: './tc-log-error-webpack.js',
|
||||||
|
output: {
|
||||||
|
file: 'lib/tc-log-error-webpack.js',
|
||||||
|
format: 'cjs'
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
input: './mocha-kotlin-reporter.js',
|
input: './mocha-kotlin-reporter.js',
|
||||||
external: ['path', 'util'],
|
external: ['path', 'util'],
|
||||||
|
|||||||
@@ -18,4 +18,4 @@ export const MESSAGE: string
|
|||||||
|
|
||||||
export function tcEscape(str: string): string
|
export function tcEscape(str: string): string
|
||||||
|
|
||||||
export function formatMessage(...str: string[]): string
|
export function formatMessage(type: string, ...str: string[]): string
|
||||||
@@ -17,6 +17,7 @@ export const BLOCK_OPENED = `##teamcity[blockOpened name='%s' flowId='%s']`
|
|||||||
export const BLOCK_CLOSED = `##teamcity[blockClosed name='%s' flowId='%s']`
|
export const BLOCK_CLOSED = `##teamcity[blockClosed name='%s' flowId='%s']`
|
||||||
|
|
||||||
export const MESSAGE = `##teamcity[message text='%s']`
|
export const MESSAGE = `##teamcity[message text='%s']`
|
||||||
|
export const TYPED_MESSAGE = `##teamcity[message text='%s' type='%s']`
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* from teamcity-service-messages
|
* from teamcity-service-messages
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import {formatMessage, TYPED_MESSAGE} from "./src/teamcity-format";
|
||||||
|
|
||||||
|
const ModuleNotFoundError = require("webpack/lib/ModuleNotFoundError")
|
||||||
|
|
||||||
|
class TeamCityErrorPlugin {
|
||||||
|
apply(compiler) {
|
||||||
|
compiler.hooks.done.tap('TeamCityErrorPlugin', (stats) => {
|
||||||
|
stats.compilation.errors.forEach(error => {
|
||||||
|
if (error instanceof ModuleNotFoundError) {
|
||||||
|
error.dependencies.forEach(dependency => {
|
||||||
|
console.error(formatMessage(TYPED_MESSAGE, `Module '${dependency.request}' not found`, 'error'))
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error(formatMessage(TYPED_MESSAGE, error.message, 'error'))
|
||||||
|
})
|
||||||
|
|
||||||
|
stats.compilation.warnings.forEach(warning => {
|
||||||
|
console.warn(formatMessage(TYPED_MESSAGE, warning.message, 'warn'))
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = TeamCityErrorPlugin;
|
||||||
Reference in New Issue
Block a user