Skip to content

Commit

Permalink
Fix Azure Devops Reporter : new change assumes Python 3.6+ (#7438)
Browse files Browse the repository at this point in the history
* It seems we don't test this codepath in default test runs, and the mentioned changes introduce a python 3.6-ism.  The fix is simply to access the RegEx's groups via the older method in all cases.

* Add expected-to-fail test to exercise failure reporting path

* New approach; specify a failure test result with all the bad characters in it like we do with JUnit and XUnit
  • Loading branch information
MattGal committed May 25, 2021
1 parent 8a53ad4 commit f22435d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def bs(match):
sym = grp[1]
if sym == 'x':
return chr(int(grp[2:], 16))
return _unescape_char_map.get(match[0][1]) or sym
return _unescape_char_map.get(match.group(0)[1]) or sym
return re.sub(r'\\x[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]?[0-9a-fA-F]?|\\[^x]', bs, value)

class XUnitFormat(ResultFormat):
Expand Down
11 changes: 11 additions & 0 deletions tests/UnitTests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@
<XUnitProject Remove="..\src\Microsoft.DotNet.Build.Tasks.VisualStudio.Tests\Microsoft.DotNet.Build.Tasks.VisualStudio.Tests.csproj"/>
</ItemGroup>

<ItemGroup>
<HelixWorkItem Include="FailingXUnitTestsTest">
<Command>echo 'done!'</Command>
<PayloadDirectory>$(MSBuildThisFileDirectory)XUnit</PayloadDirectory>
</HelixWorkItem>
</ItemGroup>
<!-- Exercise Helix failure reporting path for Xunit -->
<ItemGroup>
<AzurePipelinesExpectedTestFailure Include="XunitReportingTests.ExerciseXunitCharacterFilteringFailurePath"/>
</ItemGroup>

<ItemGroup Condition=" '$(HelixAccessToken)' != '' ">
<HelixTargetQueue Include="Debian.9.Amd64"/>
<HelixTargetQueue Include="RedHat.7.Amd64"/>
Expand Down
14 changes: 14 additions & 0 deletions tests/XUnit/testResults.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<assemblies timestamp="05/24/2021 16:33:36">
<assembly name="SomeXUnitTests.DLL" total="1" passed="0" failed="1" skipped="0" time="0.435" errors="0">
<errors />
<collection total="1" passed="0" failed="1" skipped="0" name="Test collection for XunitReportingTests" time="0.056">
<test name="XunitReportingTests.ExerciseXunitCharacterFilteringFailurePath" type="XunitReportingTests" method="ExerciseXunitCharacterFilteringFailurePath" time="0.0564499" result="Fail">
<failure exception-type="Xunit.Sdk.TrueException">
<message><![CDATA[Intentional Failure 🍕 \r \n \t \a \b \v \f \0\r\nExpected: True\r\nActual: False]]></message>
<stack-trace><![CDATA[ at XunitReportingTests.ExerciseXunitCharacterFilteringFailurePath() in Class1.cs:line 1]]></stack-trace>
</failure>
</test>
</collection>
</assembly>
</assemblies>

0 comments on commit f22435d

Please sign in to comment.