Skip to content

Commit

Permalink
[Gradle, JS] Remove redundant spaces in stacktrace
Browse files Browse the repository at this point in the history
#KT-38286 fixed
  • Loading branch information
ilgonmic committed Apr 16, 2020
1 parent 77d8864 commit 2e17357
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class TeamCityMessageCommonClient(
private val progressLogger: ProgressLogger
) : ServiceMessageParserCallback {

var afterMessage = false

private val errors = mutableListOf<String>()

private val stackTraceProcessor = TeamCityMessageStackTraceProcessor()
Expand All @@ -30,6 +32,8 @@ class TeamCityMessageCommonClient(
when (message) {
is Message -> printMessage(message.text, LogType.byValueOrNull(message.attributes["type"]))
}

afterMessage = true
}

internal fun testFailedMessage(): String {
Expand All @@ -41,18 +45,25 @@ class TeamCityMessageCommonClient(
val value = text.trimEnd()
progressLogger.progress(value)

val inStackTrace = stackTraceProcessor.process(text) { line, logType ->
val actualText = if (afterMessage)
when {
value.startsWith("\r\n") -> value.removePrefix("\r\n")
else -> value.removePrefix("\n")
}
else value

val inStackTrace = stackTraceProcessor.process(actualText) { line, logType ->
log.processLogMessage(line, logType)
errors.add(line.clearAnsiColor())
}

if (inStackTrace) return

if (type?.isErrorLike() == true) {
errors.add(value.clearAnsiColor())
errors.add(actualText.clearAnsiColor())
}

type?.let { log.processLogMessage(value, it) }
type?.let { log.processLogMessage(actualText, it) }
}

override fun regularText(text: String) {
Expand Down

0 comments on commit 2e17357

Please sign in to comment.