From f372ddea4d2b47208fd343f9f8382cedb8783faf Mon Sep 17 00:00:00 2001 From: Vasily Levchenko Date: Tue, 21 Feb 2017 15:42:50 +0300 Subject: [PATCH] reporting: TC integration escaping issues fix. - error: testFailed ignored if message or details isn't correctly escaped - fail: testFailed's message should be escaped also. --- .../org/jetbrains/kotlin/KonanTest.groovy | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy b/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy index a21976eeedd..62ef7485b6f 100644 --- a/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy +++ b/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy @@ -439,29 +439,33 @@ fun main(args : Array) { return super.pass() } + /** + * Teamcity require escaping some symbols in pipe manner. + * https://github.com/GitTools/GitVersion/issues/94 + */ + String toTeamCityFormat(String inStr) { + return inStr.replaceAll("\\|", "||") + .replaceAll("\r", "|r") + .replaceAll("\n", "|n") + .replaceAll("'", "|'") + .replaceAll("\\[", "|[") + .replaceAll("]", "|]") + + } TestResult fail(TestFailedException e) { - teamcityReport("testFailed type='comparisonFailure' name='$name' message='${e.getMessage()}'") + teamcityReport("testFailed type='comparisonFailure' name='$name' message='${toTeamCityFormat(e.getMessage())}'") teamcityFinish() return super.fail(e) } + TestResult error(Exception e) { def writer = new StringWriter() e.printStackTrace(new PrintWriter(writer)) def rawString = writer.toString() - /** - * Teamcity require escaping some symbols in pipe manner. - * https://github.com/GitTools/GitVersion/issues/94 - */ - def formatedString = rawString - .replaceAll("\\|", "||") - .replaceAll("\r", "|r") - .replaceAll("\n", "|n") - .replaceAll("'", "|'") - .replaceAll("\\[", "|[") - .replaceAll("]", "|]") - teamcityReport("testFailed name='$name' message='${e.getMessage()}' details='${formatedString}'") + + teamcityReport("testFailed name='$name' message='${toTeamCityFormat(e.getMessage())}' details='${toTeamCityFormat(rawString)}'") teamcityFinish() return super.error(e) }