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.
This commit is contained in:
committed by
vvlevchenko
parent
e59f3c0805
commit
f372ddea4d
@@ -439,29 +439,33 @@ fun main(args : Array<String>) {
|
|||||||
return super.pass()
|
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) {
|
TestResult fail(TestFailedException e) {
|
||||||
teamcityReport("testFailed type='comparisonFailure' name='$name' message='${e.getMessage()}'")
|
teamcityReport("testFailed type='comparisonFailure' name='$name' message='${toTeamCityFormat(e.getMessage())}'")
|
||||||
teamcityFinish()
|
teamcityFinish()
|
||||||
return super.fail(e)
|
return super.fail(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TestResult error(Exception e) {
|
TestResult error(Exception e) {
|
||||||
def writer = new StringWriter()
|
def writer = new StringWriter()
|
||||||
e.printStackTrace(new PrintWriter(writer))
|
e.printStackTrace(new PrintWriter(writer))
|
||||||
def rawString = writer.toString()
|
def rawString = writer.toString()
|
||||||
/**
|
|
||||||
* Teamcity require escaping some symbols in pipe manner.
|
teamcityReport("testFailed name='$name' message='${toTeamCityFormat(e.getMessage())}' details='${toTeamCityFormat(rawString)}'")
|
||||||
* 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}'")
|
|
||||||
teamcityFinish()
|
teamcityFinish()
|
||||||
return super.error(e)
|
return super.error(e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user