]> granicus.if.org Git - llvm/commitdiff
Merging r339179 and r339184:
authorHans Wennborg <hans@hanshq.net>
Mon, 13 Aug 2018 08:15:58 +0000 (08:15 +0000)
committerHans Wennborg <hans@hanshq.net>
Mon, 13 Aug 2018 08:15:58 +0000 (08:15 +0000)
------------------------------------------------------------------------
r339179 | stella.stamenova | 2018-08-07 22:54:38 +0200 (Tue, 07 Aug 2018) | 12 lines

[lit, python3] Update lit error logging to work correctly in python3 and other test fixes

Summary:
In Python2 'unicode' is a distinct type from 'str', but in Python3 'unicode' does not exist and instead all 'str' objects are Unicode string. This change updates the logic in the test logging for lit to correctly process each of the types, and more importantly, to not just fail in Python3.

This change also reverses the use of quotes in several of the cfg files. By using '""' we are guaranteeing that the resulting path will work correctly on Windows while "''" only works correctly sometimes. This also fixes one of the failing tests.

Reviewers: asmith, zturner

Subscribers: stella.stamenova, delcypher, llvm-commits

Differential Revision: https://reviews.llvm.org/D50397
------------------------------------------------------------------------

------------------------------------------------------------------------
r339184 | stella.stamenova | 2018-08-07 23:21:30 +0200 (Tue, 07 Aug 2018) | 3 lines

[lit] Disable shtest-timeout on Windows

This test passes on Windows when using Python 3 but fails when using Python 2, so it needs more investigation before it can be enabled as the bots use Python 2.
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_70@339542 91177308-0d34-0410-b5e6-96231b3b80d8

utils/lit/lit/Test.py
utils/lit/lit/llvm/config.py
utils/lit/tests/Inputs/shtest-env/lit.cfg
utils/lit/tests/Inputs/shtest-shell/lit.cfg
utils/lit/tests/Inputs/shtest-timeout/lit.cfg
utils/lit/tests/lit.cfg

index 9fa9064dc689902ab7b26a7b1b3afcacd83c0014..a10419f33fa1ba7493ca1fb0aac05ac99b8e4ff9 100644 (file)
@@ -378,10 +378,15 @@ class Test:
         fil.write(testcase_xml)
         if self.result.code.isFailure:
             fil.write(">\n\t<failure ><![CDATA[")
-            if type(self.result.output) == unicode:
-                encoded_output = self.result.output.encode("utf-8", 'ignore')
-            else:
+            # In Python2, 'str' and 'unicode' are distinct types, but in Python3, the type 'unicode' does not exist
+            # and instead 'bytes' is distinct
+            # in Python3, there's no unicode
+            if isinstance(self.result.output, str):
                 encoded_output = self.result.output
+            elif isinstance(self.result.output, bytes):
+                encoded_output = self.result.output.decode("utf-8", 'ignore')
+            else:
+                encoded_output = self.result.output.encode("utf-8", 'ignore')
             # In the unlikely case that the output contains the CDATA terminator
             # we wrap it by creating a new CDATA block
             fil.write(encoded_output.replace("]]>", "]]]]><![CDATA[>"))
index 550ba363009e544724d3f97198422e6c78b8b0ad..74c5f27c2790f698bdcf3c008aee0017a507263c 100644 (file)
@@ -299,7 +299,7 @@ class LLVMConfig(object):
                 'count'), verbatim=True, unresolved='fatal'),
             ToolSubst(r'\| \bnot\b', command=FindTool('not'), verbatim=True, unresolved='fatal')]
 
-        self.config.substitutions.append(('%python', "'%s'" % (sys.executable)))
+        self.config.substitutions.append(('%python', '"%s"' % (sys.executable)))
 
         self.add_tool_substitutions(
             tool_patterns, [self.config.llvm_tools_dir])
index 1b4715e79ac74800f9e1ad8dd2703efe7754014b..1e2d050754a797e591844097036c6b8f8a85a0a6 100644 (file)
@@ -6,4 +6,4 @@ config.test_source_root = None
 config.test_exec_root = None
 config.environment['FOO'] = '1'
 config.environment['BAR'] = '2'
-config.substitutions.append(('%{python}', "'%s'" % (sys.executable)))
+config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
index 14767f284633946cea8136e81df89567811f7a75..3231dedc714641cedb7730a7270fd4bad8cc69c2 100644 (file)
@@ -4,4 +4,4 @@ config.suffixes = ['.txt']
 config.test_format = lit.formats.ShTest()
 config.test_source_root = None
 config.test_exec_root = None
-config.substitutions.append(('%{python}', "'%s'" % (sys.executable)))
+config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
index 74f6771b923dea65b51504e8fbe81e217aadcfb6..96bf18170a8f9d74ea2e5e3581fd565c44ed98a0 100644 (file)
@@ -29,4 +29,4 @@ config.test_exec_root = config.test_source_root
 config.target_triple = '(unused)'
 src_root = os.path.join(config.test_source_root, '..')
 config.environment['PYTHONPATH'] = src_root
-config.substitutions.append(('%{python}', "'%s'" % (sys.executable)))
+config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
index 75cba3f4f045292d40a84c8521a8a42333286597..01a3431b43598388dc7c567e2aae00a6a99302b2 100644 (file)
@@ -40,7 +40,7 @@ config.substitutions.append(('%{inputs}', os.path.join(
             src_root, 'tests', 'Inputs')))
 config.substitutions.append(('%{lit}', "%%{python} %s" % (
             os.path.join(lit_path, 'lit.py'),)))
-config.substitutions.append(('%{python}', "'%s'" % (sys.executable)))
+config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
 
 
 # Enable coverage.py reporting, assuming the coverage module has been installed