[Lldb-commits] [PATCH] D19215: normalize test file extension for test filenames

Todd Fiala via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 18 12:36:16 PDT 2016


tfiala added a comment.

> The __file__ for lldbinline.py-based tests is getting set to .pyc via the unittest2 loader.  This callstack comes from inserting this code into lldbinline.py:

> 

>   diff --git a/packages/Python/lldbsuite/test/lldbinline.py b/packages/Python/lldbsuite/test/lldbinline.py

>   index 4eaa2a7..3eef4ee 100644

>   --- a/packages/Python/lldbsuite/test/lldbinline.py

>   +++ b/packages/Python/lldbsuite/test/lldbinline.py

>   @@ -206,6 +206,10 @@ def MakeInlineTest(__file, __globals, decorators=None):

>        __globals.update({test_name : test})

>   

>        # Store the name of the originating file.o

>   -    test.test_filename = __file

>   +    if __file is not None and __file.endswith(".pyc"):

>   +        raise Exception("lldbinline file ends with .pyc: {}".format(__file))

>   +        test.test_filename = __file[0:-1]

>   +    else:

>   +        test.test_filename = __file

>        return test

> 

> 

> So - I can either intercept it right there and convert to .py, or I can protect it at the API ingestion level.  If we go with the former, then I want to add an assert to the latter to make sure any cases of this sneaking in are caught.


I should mention that I verified we do *not* instruct unittest2 to load a .pyc (i.e. this isn't happening because we somehow asked it to parse a .pyc):

  diff --git a/packages/Python/lldbsuite/test/dotest.py b/packages/Python/lldbsuite/test/dotest.py
  index 198e87c..71d8c58 100644
  --- a/packages/Python/lldbsuite/test/dotest.py
  +++ b/packages/Python/lldbsuite/test/dotest.py
  @@ -744,6 +744,8 @@ def visit(prefix, dir, names):
                   # A simple case of just the module name.  Also the failover case
                   # from the filterspec branch when the (base, filterspec) combo
                   # doesn't make sense.
  +                if base is not None and base.endswith(".pyc"):
  +                   raise Exception("base ends with .pyc: {}".format(base))
                   configuration.suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base))

I'm not hitting that when I hit the callstack listed above.


http://reviews.llvm.org/D19215





More information about the lldb-commits mailing list