[PATCH] D34464: lit: Make sure testnames are unicode strings

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 21 10:53:03 PDT 2017


MatzeB created this revision.
Herald added a subscriber: mcrosier.

This fixes the problem reported in https://reviews.llvm.org/D33468

The version check feels a bit unfortunate (on the other hand I didn't want to introduce a dependency on the external six module just for this). Maybe someone knows a better way?

I'm also not sure how to unittest this: I do not want to put a file with a non-ascii name into the repository. Can leave it without a test?


Repository:
  rL LLVM

https://reviews.llvm.org/D34464

Files:
  utils/lit/lit/Test.py


Index: utils/lit/lit/Test.py
===================================================================
--- utils/lit/lit/Test.py
+++ utils/lit/lit/Test.py
@@ -1,4 +1,5 @@
 import os
+import sys
 from xml.sax.saxutils import escape
 from json import JSONEncoder
 
@@ -224,7 +225,14 @@
             self.result.output = str(e)
         
     def getFullName(self):
-        return self.suite.config.name + ' :: ' + '/'.join(self.path_in_suite)
+        testpath = '/'.join(self.path_in_suite)
+        # Test names should be unicode strings. In python2 filepaths are not
+        # necessarily unicode strings yet as listdir() tends to return them
+        # as str objects when they don't decode cleanly.
+        if sys.version_info < (3,0,0):
+            testpath = testpath.decode(sys.getfilesystemencoding(),
+                                       errors='replace')
+        return self.suite.config.name + ' :: ' + testpath
 
     def getFilePath(self):
         if self.file_path:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34464.103423.patch
Type: text/x-patch
Size: 982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170621/869c5eb4/attachment.bin>


More information about the llvm-commits mailing list