[llvm] r332148 - Overhaul unicode handling in xunit output
Chris Matthews via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 6 07:18:46 PDT 2018
I’ll take a peek. I’m sure I can sort out something.
💬 from 📱
> On Jun 6, 2018, at 12:14 AM, Michał Górny <mgorny at gentoo.org> wrote:
>
> W dniu pią, 11.05.2018 o godzinie 22∶18 +0000, użytkownik Chris Matthews
> via llvm-commits napisał:
>> Author: cmatthews
>> Date: Fri May 11 15:18:22 2018
>> New Revision: 332148
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=332148&view=rev
>> Log:
>> Overhaul unicode handling in xunit output
>>
>> I have seen a lot of errors where the xunit does not encode unicode
>> test output correctly. Handle that explicitly now.
>>
>> Modified:
>> llvm/trunk/utils/lit/lit/Test.py
>>
>> Modified: llvm/trunk/utils/lit/lit/Test.py
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/Test.py?rev=332148&r1=332147&r2=332148&view=diff
>> ==============================================================================
>> --- llvm/trunk/utils/lit/lit/Test.py (original)
>> +++ llvm/trunk/utils/lit/lit/Test.py Fri May 11 15:18:22 2018
>> @@ -371,15 +371,19 @@ class Test:
>> class_name = safe_name + "." + "/".join(safe_test_path)
>> else:
>> class_name = safe_name + "." + safe_name
>> - testcase_template = u"<testcase classname='{class_name}' name='{test_name}' time='{time:.2f}'"
>> + testcase_template = "<testcase classname='{class_name}' name='{test_name}' time='{time:.2f}'"
>> elapsed_time = self.result.elapsed if self.result.elapsed is not None else 0.0
>> testcase_xml = testcase_template.format(class_name=class_name, test_name=test_name, time=elapsed_time)
>> fil.write(testcase_xml)
>> if self.result.code.isFailure:
>> - fil.write(u">\n\t<failure ><![CDATA[")
>> - fil.write(self.result.output)
>> - fil.write(u"]]></failure>\n</testcase>")
>> + fil.write(">\n\t<failure ><![CDATA[")
>> + if type(self.result.output) == unicode:
>> + encoded_output = self.result.output.encode("utf-8", 'ignore')
>> + else:
>> + encoded_output = self.result.output
>> + fil.write(encoded_output)
>> + fil.write("]]></failure>\n</testcase>")
>> elif self.result.code == UNSUPPORTED:
>> - fil.write(u">\n\t<skipped />\n</testcase>\n")
>> + fil.write(">\n\t<skipped />\n</testcase>\n")
>> else:
>> - fil.write(u"/>")
>> + fil.write("/>")
>>
>
> FYI, this broke Python 3 support in lit:
>
> Traceback (most recent call last):
> File "/usr/src/llvm/utils/lit/tests/../lit.py", line 7, in <module>
> main()
> File "/usr/src/llvm/utils/lit/lit/main.py", line 193, in main
> main_with_tmp(builtinParameters)
> File "/usr/src/llvm/utils/lit/lit/main.py", line 623, in main_with_tmp
> result_test.writeJUnitXML(xunit_output_file)
> File "/usr/src/llvm/utils/lit/lit/Test.py", line 381, in writeJUnitXML
> if type(self.result.output) == unicode:
> NameError: name 'unicode' is not defined
>
> That said, I'm sorry but I wasn't able to find a solution that didn't
> make things worse ;-).
>
> --
> Best regards,
> Michał Górny
>
More information about the llvm-commits
mailing list