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

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 15 05:42:13 PDT 2018


Thanks! I have confirmed they are fine.

On Mon, Aug 13, 2018 at 5:16 PM Hans Wennborg <hans at chromium.org> wrote:

> I've merged r339073 in r339541 to avoid conflicts, and this one
> together with r339184 in r339542.
>
> On Sat, Aug 11, 2018 at 2:33 PM, NAKAMURA Takumi via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> > At least, part of it, llvm/trunk/utils/lit/lit/Test.py, should be fed to
> > release_70 for compatibility of Py3.
> >
> > On Wed, Aug 8, 2018 at 5:55 AM Stella Stamenova via llvm-commits
> > <llvm-commits at lists.llvm.org> wrote:
> >>
> >> Author: stella.stamenova
> >> Date: Tue Aug  7 13:54:38 2018
> >> New Revision: 339179
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=339179&view=rev
> >> Log:
> >> [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
> >>
> >> Modified:
> >>     llvm/trunk/utils/lit/lit/Test.py
> >>     llvm/trunk/utils/lit/lit/llvm/config.py
> >>     llvm/trunk/utils/lit/tests/Inputs/shtest-env/lit.cfg
> >>     llvm/trunk/utils/lit/tests/Inputs/shtest-shell/lit.cfg
> >>     llvm/trunk/utils/lit/tests/Inputs/shtest-timeout/lit.cfg
> >>     llvm/trunk/utils/lit/tests/lit.cfg
> >>     llvm/trunk/utils/lit/tests/shtest-timeout.py
> >>
> >> Modified: llvm/trunk/utils/lit/lit/Test.py
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/Test.py?rev=339179&r1=339178&r2=339179&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/utils/lit/lit/Test.py (original)
> >> +++ llvm/trunk/utils/lit/lit/Test.py Tue Aug  7 13:54:38 2018
> >> @@ -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[>"))
> >>
> >> Modified: llvm/trunk/utils/lit/lit/llvm/config.py
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/llvm/config.py?rev=339179&r1=339178&r2=339179&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/utils/lit/lit/llvm/config.py (original)
> >> +++ llvm/trunk/utils/lit/lit/llvm/config.py Tue Aug  7 13:54:38 2018
> >> @@ -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])
> >>
> >> Modified: llvm/trunk/utils/lit/tests/Inputs/shtest-env/lit.cfg
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/shtest-env/lit.cfg?rev=339179&r1=339178&r2=339179&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/utils/lit/tests/Inputs/shtest-env/lit.cfg (original)
> >> +++ llvm/trunk/utils/lit/tests/Inputs/shtest-env/lit.cfg Tue Aug  7
> >> 13:54:38 2018
> >> @@ -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)))
> >>
> >> Modified: llvm/trunk/utils/lit/tests/Inputs/shtest-shell/lit.cfg
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/shtest-shell/lit.cfg?rev=339179&r1=339178&r2=339179&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/utils/lit/tests/Inputs/shtest-shell/lit.cfg (original)
> >> +++ llvm/trunk/utils/lit/tests/Inputs/shtest-shell/lit.cfg Tue Aug  7
> >> 13:54:38 2018
> >> @@ -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)))
> >>
> >> Modified: llvm/trunk/utils/lit/tests/Inputs/shtest-timeout/lit.cfg
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/shtest-timeout/lit.cfg?rev=339179&r1=339178&r2=339179&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/utils/lit/tests/Inputs/shtest-timeout/lit.cfg (original)
> >> +++ llvm/trunk/utils/lit/tests/Inputs/shtest-timeout/lit.cfg Tue Aug  7
> >> 13:54:38 2018
> >> @@ -29,4 +29,4 @@ config.test_exec_root = config.test_sour
> >>  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)))
> >>
> >> Modified: llvm/trunk/utils/lit/tests/lit.cfg
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/lit.cfg?rev=339179&r1=339178&r2=339179&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/utils/lit/tests/lit.cfg (original)
> >> +++ llvm/trunk/utils/lit/tests/lit.cfg Tue Aug  7 13:54:38 2018
> >> @@ -40,7 +40,7 @@ config.substitutions.append(('%{inputs}'
> >>              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
> >>
> >> Modified: llvm/trunk/utils/lit/tests/shtest-timeout.py
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/shtest-timeout.py?rev=339179&r1=339178&r2=339179&view=diff
> >>
> >>
> ==============================================================================
> >> --- llvm/trunk/utils/lit/tests/shtest-timeout.py (original)
> >> +++ llvm/trunk/utils/lit/tests/shtest-timeout.py Tue Aug  7 13:54:38
> 2018
> >> @@ -1,8 +1,5 @@
> >>  # REQUIRES: python-psutil
> >>
> >> -# PR33944
> >> -# XFAIL: windows
> >> -
> >>  # FIXME: This test is fragile because it relies on time which can
> >>  # be affected by system performance. In particular we are currently
> >>  # assuming that `short.py` can be successfully executed within 2
> >>
> >>
> >> _______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180815/32bc7e99/attachment.html>


More information about the llvm-commits mailing list