You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please see the reproduction repo. It contains one test.
Point TeamCity at the repo
Add a 'Nuget Restore step' in the beginning
Add an off-the-shelf xUnit runner step with '**/*.Tests.dll'
Observe:
Despite the runner exits with non-zero code (thus correctly failing the build), the TeamCity report shows the test itself as successful.
Analysis
Inspecting the log shows a message:
##teamcity[testFailed name='xUnitInTeamCity.ReproForUnicodeEscapingIssue.Tests.IssueReproTests.FailWithMessageContainingNonAsciiChars' details='Assert.Equal() Failure|r|n (pos 0)|r|nExpected: ' +Ø%D|r|nActual: anything different so that test fails|r|n (pos 0)|r|n at xUnitInTeamCity.ReproForUnicodeEscapingIssue.Tests.IssueReproTests.FailWithMessageContainingNonAsciiChars() in d:\Teamcity\BuildAgent\work\c80283b4cb57ca79\xUnitInTeamCity.ReproForUnicodeEscapingIssue.Tests\IssueReproTests.cs:line 25' flowId='4862240aeba54317941ec7648b984516']
Incorrect property name.
Valid property list format is (name( )=( )'escaped_value'( )) where escape symbol is "|"
As noted in the repro source, we have traced this down to the problem of console encoding, which causes the special characters to be changed to their 'simplified non-Unicode' version upon output. Especially the ’ (RIGHT SINGLE QUOTATION MARK) character is of note, because it gets changed to simple ', which gets to TeamCity unescaped and prevents it from receiving the test failure command.
Severity
As for severity, while thanks to the non-zero exit code the developers should notice the problem, some wrapping scripts may sometimes not pass that to the end, making the failure completely unnoticed (notably xUnit.net-dotCover from meta-runner-power-pack has this issue as of present).
Fix suggestion
Even though some solutions may exist which make the pipeline not change the characters, I think that it might be good to implement a fix that works out-of-the-box in any setup. That is, just use the TeamCity's \uNNNN escaping for any special characters beyond ASCII. After all, these commands are not seen by human in a normal run. The extra benefit will be that all other special characters will start showing in TeamCity without getting changed.
Take note there's even a similar Pull Request to in JetBrains' utility library for outputting the commands that also suggest always doing it under the hood.
The text was updated successfully, but these errors were encountered:
@s3rius2 Thank you for noticing and a very good analysis! And also a repro!
I must say I'm not sure exactly where this happens, though. The output is basically passed straight through to TeamCity's internals:
Using xUnit 2.2 and TeamCity 10.0.4 on Windows.
Reproduction
Please see the reproduction repo. It contains one test.
Point TeamCity at the repo
Add a 'Nuget Restore step' in the beginning
Add an off-the-shelf xUnit runner step with '**/*.Tests.dll'
Observe:
Despite the runner exits with non-zero code (thus correctly failing the build), the TeamCity report shows the test itself as successful.
Analysis
Inspecting the log shows a message:
##teamcity[testFailed name='xUnitInTeamCity.ReproForUnicodeEscapingIssue.Tests.IssueReproTests.FailWithMessageContainingNonAsciiChars' details='Assert.Equal() Failure|r|n (pos 0)|r|nExpected: ' +Ø%D|r|nActual: anything different so that test fails|r|n (pos 0)|r|n at xUnitInTeamCity.ReproForUnicodeEscapingIssue.Tests.IssueReproTests.FailWithMessageContainingNonAsciiChars() in d:\Teamcity\BuildAgent\work\c80283b4cb57ca79\xUnitInTeamCity.ReproForUnicodeEscapingIssue.Tests\IssueReproTests.cs:line 25' flowId='4862240aeba54317941ec7648b984516']
Incorrect property name.
Valid property list format is (name( )=( )'escaped_value'( )) where escape symbol is "|"
As noted in the repro source, we have traced this down to the problem of console encoding, which causes the special characters to be changed to their 'simplified non-Unicode' version upon output. Especially the ’ (RIGHT SINGLE QUOTATION MARK) character is of note, because it gets changed to simple ', which gets to TeamCity unescaped and prevents it from receiving the test failure command.
Severity
As for severity, while thanks to the non-zero exit code the developers should notice the problem, some wrapping scripts may sometimes not pass that to the end, making the failure completely unnoticed (notably xUnit.net-dotCover from meta-runner-power-pack has this issue as of present).
Fix suggestion
Even though some solutions may exist which make the pipeline not change the characters, I think that it might be good to implement a fix that works out-of-the-box in any setup. That is, just use the TeamCity's \uNNNN escaping for any special characters beyond ASCII. After all, these commands are not seen by human in a normal run. The extra benefit will be that all other special characters will start showing in TeamCity without getting changed.
Take note there's even a similar Pull Request to in JetBrains' utility library for outputting the commands that also suggest always doing it under the hood.
The text was updated successfully, but these errors were encountered: