Skip to content

Commit

Permalink
Junit XML: Fix invalid characters in generated report
Browse files Browse the repository at this point in the history
When generating reports with invalid characters, Azure Pipelines will
report an error and not parse the file. This applies to any character
not in the allowed character range of XML 1.0 specification [1].

Fixed by removing all invalid characters before serialization.

[1] https://www.w3.org/TR/REC-xml/#charsets
  • Loading branch information
logmanoriginal committed Jan 7, 2024
1 parent ec4f2e1 commit 11379cd
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 19 deletions.
1 change: 1 addition & 0 deletions Caraya JUnit for Azure Pipelines.lvproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</Item>
<Item Name="Tests" Type="Folder">
<Item Name="JUnit Conversion Tests.lvlib" Type="Library" URL="../Tests/JUnit Conversion Tests/JUnit Conversion Tests.lvlib"/>
<Item Name="JUnit XML Tests.lvlib" Type="Library" URL="../Tests/JUnit XML Tests/JUnit XML Tests.lvlib"/>
</Item>
<Item Name="JUnit Conversion.lvlib" Type="Library" URL="../JUnit Conversion/JUnit Conversion.lvlib"/>
<Item Name="JUnit for Azure Pipelines.lvclass" Type="LVClass" URL="../JUnit for Azure Pipelines/JUnit for Azure Pipelines.lvclass"/>
Expand Down
40 changes: 21 additions & 19 deletions JUnit XML/JUnit XML.lvlib

Large diffs are not rendered by default.

Binary file added JUnit XML/Normalize String.vi
Binary file not shown.
Binary file modified JUnit XML/Test Case/Serialize.vi
Binary file not shown.
Binary file modified JUnit XML/Test Suite/Serialize.vi
Binary file not shown.
Binary file added Tests/JUnit XML Tests/Get Invalid Chars.vi
Binary file not shown.
20 changes: 20 additions & 0 deletions Tests/JUnit XML Tests/JUnit XML Tests.lvlib
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version='1.0' encoding='UTF-8'?>
<Library LVVersion="13008000">
<Property Name="NI.Lib.Icon" Type="Bin">%Q#!!!!!!!)!"1!&amp;!!!-!%!!!@````]!!!!"!!%!!!(]!!!*Q(C=\&gt;7R=2MR%!81N=?"5X&lt;A91M&lt;/W-,&lt;'&amp;&lt;9+K1,7Q,&lt;)%N&lt;!NMA3X)DW?-RJ(JQ"I\%%Z,(@`BA#==ZB3RN;]28_,V7@P_W`:R`&gt;HV*SU_WE@\N_XF[3:^^TX\+2YP)D7K6;G-RV3P)R`ZS%=_]J'XP/5N&lt;XH,7V\SEJ?]Z#5P?=J4HP+5JTTFWS%0?=B$DD1G(R/.1==!IT.+D)`B':\B'2Z@9XC':XC':XBUC?%:HO%:HO&amp;R7QT0]!T0]!S0I4&lt;*&lt;)?=:XA-(]X40-X40-VDSGC?"GC4N9(&lt;)"D2,L;4ZGG?ZH%;T&gt;-]T&gt;-]T?.S.%`T.%`T.)^&lt;NF8J4@-YZ$S'C?)JHO)JHO)R&gt;"20]220]230[;*YCK=ASI2F=)1I.Z5/Z5PR&amp;)^@54T&amp;5TT&amp;5TQO&lt;5_INJ6Z;"[(H#&gt;ZEC&gt;ZEC&gt;Z$"(*ETT*ETT*9^B)HO2*HO2*(F.&amp;]C20]C2)GN4UE1:,.[:/+5A?0^NOS?UJ^3&lt;*\9B9GT@7JISVW7*NIFC&lt;)^:$D`5Q9TWE7)M@;V&amp;D,6;M29DVR]6#R],%GC47T9_/=@&gt;Z5V&gt;V57&gt;V5E&gt;V5(OV?^T[FTP?\`?YX7ZRP6\D=LH%_8S/U_E5R_-R$I&gt;$\0@\W/VW&lt;[_"&lt;Y[X&amp;],0^^+,]T_J&gt;`J@_B_]'_.T`$KO.@I"O[^NF!!!!!!</Property>
<Property Name="NI.Lib.SourceVersion" Type="Int">318799872</Property>
<Property Name="NI.Lib.Version" Type="Str">1.0.0.0</Property>
<Property Name="NI.LV.All.SourceOnly" Type="Bool">true</Property>
<Item Name="Support" Type="Folder">
<Property Name="NI.LibItem.Scope" Type="Int">2</Property>
<Item Name="Get Invalid Chars.vi" Type="VI" URL="../Get Invalid Chars.vi"/>
</Item>
<Item Name="Normalize String - String with Invalid Character - Normalized String does not contain Invalid Character.vi" Type="VI" URL="../Normalize String - String with Invalid Character - Normalized String does not contain Invalid Character.vi"/>
<Item Name="Test Case.Serialize - Invalid character in Classname - XML does not contain invalid character.vi" Type="VI" URL="../Test Case.Serialize - Invalid character in Classname - XML does not contain invalid character.vi"/>
<Item Name="Test Case.Serialize - Invalid character in Message - XML does not contain invalid character.vi" Type="VI" URL="../Test Case.Serialize - Invalid character in Message - XML does not contain invalid character.vi"/>
<Item Name="Test Case.Serialize - Invalid character in Name - XML does not contain invalid character.vi" Type="VI" URL="../Test Case.Serialize - Invalid character in Name - XML does not contain invalid character.vi"/>
<Item Name="Test Case.Serialize - Invalid character in Stack Trace - XML does not contain invalid character.vi" Type="VI" URL="../Test Case.Serialize - Invalid character in Stack Trace - XML does not contain invalid character.vi"/>
<Item Name="Test Case.Serialize - Invalid character in Type - XML does not contain invalid character.vi" Type="VI" URL="../Test Case.Serialize - Invalid character in Type - XML does not contain invalid character.vi"/>
<Item Name="Test Suite.Serialize - Invalid character in Hostname - XML does not contain invalid character.vi" Type="VI" URL="../Test Suite.Serialize - Invalid character in Hostname - XML does not contain invalid character.vi"/>
<Item Name="Test Suite.Serialize - Invalid character in Name - XML does not contain invalid character.vi" Type="VI" URL="../Test Suite.Serialize - Invalid character in Name - XML does not contain invalid character.vi"/>
<Item Name="Test Suite.Serialize - Invalid character in Package - XML does not contain invalid character.vi" Type="VI" URL="../Test Suite.Serialize - Invalid character in Package - XML does not contain invalid character.vi"/>
</Library>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 11379cd

Please sign in to comment.