llvm.org GIT mirror llvm / 6389250
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339179 91177308-0d34-0410-b5e6-96231b3b80d8 Stella Stamenova 1 year, 3 months ago
7 changed file(s) with 13 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
377377 fil.write(testcase_xml)
378378 if self.result.code.isFailure:
379379 fil.write(">\n\t
380 if type(self.result.output) == unicode:
380 # In Python2, 'str' and 'unicode' are distinct types, but in Python3, the type 'unicode' does not exist
381 # and instead 'bytes' is distinct
382 # in Python3, there's no unicode
383 if isinstance(self.result.output, str):
384 encoded_output = self.result.output
385 elif isinstance(self.result.output, bytes):
386 encoded_output = self.result.output.decode("utf-8", 'ignore')
387 else:
381388 encoded_output = self.result.output.encode("utf-8", 'ignore')
382 else:
383 encoded_output = self.result.output
384389 # In the unlikely case that the output contains the CDATA terminator
385390 # we wrap it by creating a new CDATA block
386391 fil.write(encoded_output.replace("]]>", "]]]]>"))
298298 'count'), verbatim=True, unresolved='fatal'),
299299 ToolSubst(r'\| \bnot\b', command=FindTool('not'), verbatim=True, unresolved='fatal')]
300300
301 self.config.substitutions.append(('%python', "'%s'" % (sys.executable)))
301 self.config.substitutions.append(('%python', '"%s"' % (sys.executable)))
302302
303303 self.add_tool_substitutions(
304304 tool_patterns, [self.config.llvm_tools_dir])
55 config.test_exec_root = None
66 config.environment['FOO'] = '1'
77 config.environment['BAR'] = '2'
8 config.substitutions.append(('%{python}', "'%s'" % (sys.executable)))
8 config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
33 config.test_format = lit.formats.ShTest()
44 config.test_source_root = None
55 config.test_exec_root = None
6 config.substitutions.append(('%{python}', "'%s'" % (sys.executable)))
6 config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
2828 config.target_triple = '(unused)'
2929 src_root = os.path.join(config.test_source_root, '..')
3030 config.environment['PYTHONPATH'] = src_root
31 config.substitutions.append(('%{python}', "'%s'" % (sys.executable)))
31 config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
3939 src_root, 'tests', 'Inputs')))
4040 config.substitutions.append(('%{lit}', "%%{python} %s" % (
4141 os.path.join(lit_path, 'lit.py'),)))
42 config.substitutions.append(('%{python}', "'%s'" % (sys.executable)))
42 config.substitutions.append(('%{python}', '"%s"' % (sys.executable)))
4343
4444
4545 # Enable coverage.py reporting, assuming the coverage module has been installed
0 # REQUIRES: python-psutil
1
2 # PR33944
3 # XFAIL: windows
41
52 # FIXME: This test is fragile because it relies on time which can
63 # be affected by system performance. In particular we are currently